Matlab GUI- Workspace to GUI display
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Adam
le 4 Nov 2015
Modifié(e) : Adam
le 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 commentaires
Adam
le 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.
Arunkumar Muthukumaran
le 19 Déc 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!