Transfering variables from Workspace to GUIDE Interfaz
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
DeYong
am 16 Nov. 2012
Bearbeitet: Alex Yugcha
am 12 Sep. 2020
Hello Everybody I would like to ask you the following question:
I have a set of variables that I have generated in the MATLAB Workspace. I also created a GUIDE Interfaz to process this variables. I would like to be able to select those variables from the GUI but I don´t know how to incorporate some windows that allows me to do that. I surfed in different sites but I could not find some help. I would appreciate your help.
Thank you in advance.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Arthur
am 16 Nov. 2012
2 Kommentare
Arthur
am 28 Nov. 2012
Ok, so you first want a list of variables from the base workspace, and then select one of those. You need to make a simple GUI containing a listbox. In the openingFcn of the GUI you retrieve the variable names from the base and store these in your listbox, like this:
varnames = evalin('base','who'); %get variables from workspace
set(handles.listbox1,'String',varnames); %put names in listbox
In the callback of the listbox, you can get the values that you need.
varnames = get(handles.listbox1,'String') %get variable names;
sel = get(handles.listbox1,'Value') %get selected variable;
myVarName = varnames{sel}; %get name of selected variable;
myVarValue = evalin('base',myVarName);
Alex Yugcha
am 12 Sep. 2020
Bearbeitet: Alex Yugcha
am 12 Sep. 2020
Hello, i used code from Arthur
I have this in workspace:
then i have created a GUI
In the Opening Fcn
varnames = evalin('base','who'); %get variables from workspace
set(handles.listbox1,'String',varnames); %put names in listbox
In the 'GRAFICAR'_Callback
varnames = get(handles.listbox1,'String') %get variable names;
t = varnames{1}; %get name of selected variable;
y =varnames{2};
t = evalin('base',t);
y = evalin('base',y);
axes(handles.axes1)
plot(t,y);
Then I could draw my function 'y' directly on the axis
0 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!