Matlab GUI- Workspace to GUI display
조회 수: 5 (최근 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!