GUI for existing function in matlab

I have an existing function (ex) that will take inputs to continue the code I wrote now I want to create a GUI for this function how can I call a GUI for this function???

3 Comments

Dennis
Dennis on 25 Apr 2018
Edited: Dennis on 25 Apr 2018
Do you want to open a GUI with your function or do you want to a GUI that can call your function?
And what is that GUI supposed to do?
the function should take inputs which will be used in the code so the inputs should be entering in an interface
Without knowing what kind of input you need/ how many parameters you have or what your function looks like i can only provide an easy example. I was guessing that your inputs are numbers, my example wont work with anything else.
function simpleUI ()
fig=figure;
mydata.uihandles(1)=uicontrol('Style','edit','String','Para 1','Position',[20 100 100 40]);
mydata.uihandles(2)=uicontrol('Style','edit','String','Para 1','Position',[20 200 100 40]);
mydata.uihandles(3)=uicontrol('Style','pushbutton','String', 'Click me','Callback',@simpleUI_callback,'Position',[20 300 100 40]);
guidata(fig,mydata)
end
function simpleUI_callback (hObj,~ )
mydata=guidata(hObj);
uihandles=mydata.uihandles;
parameter(1)=str2double(get(uihandles(1),'String'));
parameter(2)=str2double(get(uihandles(2),'String'));
%do stuff
end

Sign in to comment.

Answers (0)

Asked:

on 25 Apr 2018

Commented:

on 25 Apr 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!