How to access variable from workspace and set it as value of a text box.
2 views (last 30 days)
Show older comments
z = evalin('base', 'z');
numfig = [1];
denfig = [1 0];
sys = tf([numfig],[denfig]);
set(handles.text9, 'String', num2str(z));
set(handles.numtxt, 'String', num2str(numfig));
set(handles.dentxt, 'String', num2str(denfig));
0 Comments
Answers (2)
Stephen23
on 15 Aug 2015
Read these:
And avoid using unreliable, slow and buggy operation like evalin (the following link discusses eval, but the same points also apply to evalin):
2 Comments
Walter Roberson
on 15 Aug 2015
Use guidata() if you are already using the handles structure. For example,
handles.MyVariable = qx17; %where qx17 is the variable to send
guidata(gcf, handles); %update the master copy
then in the routine that needs the value, if the handles structure is already there,
qx17 = handles.MyVariable; %pull out the saved value
Image Analyst
on 15 Aug 2015
You don't need to access the base workspace - I never do. See the FAQ to learn several better methods of sharing variables between your individual functions' workspaces. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!