Doç. Dr. GÜRAY SONUGÜR

Doç. Dr. Güray SONUGÜR – Öğrenci Bilgi Paylaşım Platformu

Matlab İle Analiz Ders-11 GUI

Bu çalışmada birinci ve İkinci değer isimli edit text’lere yazılan string ifadeler Topla butonuna basılınca toplanıyor, Böl butonuna basılınca ise ‘_’ karakterine göre bölünüyor.

function varargout = untitled(varargin)

gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @untitled_OpeningFcn, …
‘gui_OutputFcn’, @untitled_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code – DO NOT EDIT
% — Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled (see VARARGIN)

% Choose default command line output for untitled
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

function editBirinci_Callback(hObject, eventdata, handles)
% hObject handle to editBirinci (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of editBirinci as text
% str2double(get(hObject,’String’)) returns contents of editBirinci as a double
% — Executes during object creation, after setting all properties.
function editBirinci_CreateFcn(hObject, eventdata, handles)
% hObject handle to editBirinci (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end

function editIkinci_Callback(hObject, eventdata, handles)
% hObject handle to editIkinci (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of editIkinci as text
% str2double(get(hObject,’String’)) returns contents of editIkinci as a double
% — Executes during object creation, after setting all properties.
function editIkinci_CreateFcn(hObject, eventdata, handles)
% hObject handle to editIkinci (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes on button press in btnTopla.
function btnTopla_Callback(hObject, eventdata, handles)
% hObject handle to btnTopla (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ilk=get(handles.editBirinci,’String’); %edit text’lerden karakterler okunuyor.
iki=get(handles.editIkinci,’String’); %edit text’lerden karakterler okunuyor.
sonuc=strcat(ilk,iki);%okunan değerler birleştirildi.
%sonuç edit text’ine bulunan değer yazdırıldı.
set(handles.editSonuc,’String’,sonuc);
%bulunan değerin diğer function’larda da kullanılabilmesi için handle
%edildi.
handles.sonuc=sonuc;
guidata(hObject,handles);
function editSonuc_Callback(hObject, eventdata, handles)
% hObject handle to editSonuc (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,’String’) returns contents of editSonuc as text
% str2double(get(hObject,’String’)) returns contents of editSonuc as a double
% — Executes during object creation, after setting all properties.
function editSonuc_CreateFcn(hObject, eventdata, handles)
% hObject handle to editSonuc (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes on button press in btnBol.
function btnBol_Callback(hObject, eventdata, handles)
% hObject handle to btnBol (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
deger=strsplit(handles.sonuc,’_’); %’_’ karakterine göre string bölünüyor.
set(handles.editBirinci,’String’,deger{1}); %’_’ karakterinin solu ilk edit text’e yazdırıldı
set(handles.editIkinci,’String’,deger{2}); %’_’ karakterinin sağı ikinci edit text’e yazdırıldı