Matlab GUI- Workspace to GUI display

7 views (last 30 days)
Nitesh
Nitesh on 4 Nov 2015
I want to put the workspace variable value(s) from Matlab Workspace into the GUI to display in the text area highlighted yellow. My simulation happens with a m-file working online tuning and stored the value in the workspace. After each complete final value is stored in the workspace, i would like to use a pushbutton name (show output) and display it in the text box.
function output_Callback(hObject, eventdata, handles)
% hObject handle to output (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Kp
Kp=Kp
set(handles.output,'String',num2str(Kp))
I have even tried using global declaration but no success. My objective is to use the PUSHBUTTON and get the value display for all the parameters from the workspace which is available.. please help. Thank you
Nitesh

Answers (2)

Adam
Adam on 4 Nov 2015
Edited: Adam on 4 Nov 2015
Put them all in a struct and pass it in as an argument to the GUI.
Then initialise the ui components from that. You will have to launch the GUI from command line (or a script or function) though to do this as e.g.
MyGUI( someStruct );
You could pass them all in as individual arguments if you prefer, but that seems a little excessive.
  4 Comments
Nitesh
Nitesh on 4 Nov 2015
Hi Adam,
I still cannot display those values in the text box. The m-file is ran from the gui pushbutton and values are stored in the workspace. however, i have used
assignin('base','Kp',Kp)
to save it in the workspace from the gui function file. Can i use this command somehow??
Adam
Adam on 4 Nov 2015
If you instead do something like
handles.results.Kp = Kp;
guidata( hObject, handles )
after you run the algorithm from the GUI then you can then use the syntax above. I have never used assignin nor seen any obvious reason why it would be used in general. If you are working within a GUI keep everything in the GUI rather than dumping things to the base workspace.

Sign in to comment.


Arunkumar Muthukumaran
Arunkumar Muthukumaran on 19 Dec 2015
You can pass the variable Kp to a function (say MATLAB function) and update GUI handles with the value. This lets you to have the updated value in GUI after each timestep.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!