Matlab GUI- Workspace to GUI display
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Adam
2015-11-4
编辑:Adam
2015-11-4
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 个评论
Adam
2015-11-4
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.
Arunkumar Muthukumaran
2015-12-19
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!