Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
run external function within gui

Subject: run external function within gui

From: Edwin

Date: 15 Jul, 2010 13:20:21

Message: 1 of 1

hello everybody,
I have made a GUI with guide.The goal of the GUI I made is to get input data and save the filenames in the workspace, I have done that but then what I want is that one button in the GUI executes an external function anyone could give me any idea.

the user can push either analysis1 or analysis2 button which should execute some external function which is called dist_histo_nadv12modfmain.m, this external function then call other subfunction within it.


any help would be greatly appreciate it.

regards


below is a small part of my GUI code
--------------------------------------------------------------------------------------------------------------------
function prueba2nad(varargin)
%

% --- Executes on button press in filename1.
function filename1_Callback(hObject, eventdata, handles)
% hObject handle to filename1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,PathName] = uigetfile('*.*','Select Seismicity file');
%file = strcat(PathName,FileName)
%evalin('base',['load ' FileName]);
fname = fullfile(PathName, FileName);
%answer = inputdlg(prompt,title,lines,def);
assignin('base','A',fname);
%assignin('base','cmap',answer{2});

% --- Executes on button press in filename2.
function filename2_Callback(hObject, eventdata, handles)
% hObject handle to filename2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = ...
     uigetfile({'*.txt';'*.mat';'*.*'},'Select Source zones file');
 NAME = [pathname,filename]; %path and name
%evalin('base',['load ' filename]);
%name = fullfile('', filename);
%answer = inputdlg(prompt,title,lines,def);
assignin('base','name',filename);


% --- Executes on button press in analysis1.
function analysis1_Callback(hObject, eventdata, handles)
% hObject handle to analysis1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
assignin('base','opt',2);
pe = get(handles.input1_editText,'String');
T = get(handles.input2_editText,'String');
assignin('base','pe',pe);
assignin('base','T',T);
dist_histo_nadv12modfmain
%dist_histo_nadv12modfmain(A,BB,name,pe,T)
close(handles.figure1)



% --- Executes on button press in analysis2.
function analysis2_Callback(hObject, eventdata, handles)
% hObject handle to analysis2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
assignin('base','BC',BB);
clear BB
assignin('base','opt',1);
pe = get(handles.input1_editText,'String');
T = get(handles.input2_editText,'String');
assignin('base','pe',pe);
assignin('base','T',T);
dist_histo_nadv12modfmain
%dist_histo_nadv12modfmain(A,BC,name,pe,T)
close(handles.figure1)


% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(handles.figure1)





function input1_editText_Callback(hObject, eventdata, handles)
% hObject handle to input1_editText (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 input1_editText as text
% str2double(get(hObject,'String')) returns contents of input1_editText as a double
input = str2num(get(hObject,'String'));
if (isempty(input))
     set(hObject,'String','0')
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function input1_editText_CreateFcn(hObject, eventdata, handles)
% hObject handle to input1_editText (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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us