Transfering variables from Workspace to GUIDE Interfaz

2 次查看(过去 30 天)
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.

采纳的回答

DeYong
DeYong 2012-11-28
Thank you very much Arthur.I´ll try with your solution. It seems to be perfect. If I had some other proble I´ll post again. Thanks a lot-

更多回答(2 个)

Arthur
Arthur 2012-11-16
You can retrieve variables from the base workspace using evalin.
  2 个评论
DeYong
DeYong 2012-11-27
编辑:DeYong 2012-11-27
Thank you for your Answer. It is half usefull for my purpose. I need a function (or an arrange of them) that allow me to choose, by mean a menú or something similar to a uiget function, wich variable from workspace I will load in a variable. By mean evalin the name of the variable that a I will have to be pre established. Thanks you again. I could not solve my proble yet.
Arthur
Arthur 2012-11-28
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
Alex Yugcha 2020-9-12
编辑:Alex Yugcha 2020-9-12
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

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by