필터 지우기
필터 지우기

Can I display the simulink scope in a GUI?

조회 수: 6 (최근 30일)
Gustavo Amorim
Gustavo Amorim 2012년 9월 6일
답변: Jasmine Poppick 2024년 4월 26일
I'm designing a GUI that calculate PID parameters, this GUI passes the Kp, Ki, Kd parameters to PID Controller on simulink and then simulate it. I'd like to display the scope of simulation (scope block) in a GUI window. How could I do it?

답변 (3개)

TAB
TAB 2012년 9월 6일
Log your data coming in the simulink scope to base workspace and plot the data in your gui after simulation.
To enable the scope data logging double click on scope, go to "Scope parameters --> History" and select "Save data to workspace". Structure with time is the best suitable format for data logging.
Now after simulation, scope data will be save in the base workspace.
To plot the data
plot(ScopeData.time,ScopeData.signals.values)
  댓글 수: 3
TAB
TAB 2012년 9월 22일
You can use a button to plot the data after simulation. In the button's callback you can use the plot command.
Just for check, after the simulation, call plot command from your workspace. It opens a new figure with graph plotted on it.
Edgar Ahh
Edgar Ahh 2021년 1월 17일
I need see it on real -time this graph in GUI. How I can do it?

댓글을 달려면 로그인하십시오.


Craig
Craig 2012년 9월 6일
I've made a similar script for optimising parameters in a Simulink model. If one uses the sim(model) in the GUI's script, by default this returns some variable yout of simulation results, the first row being timestep - as you probably know.
Then one could use setappdata and getappdata to transfer the data between callbacks.
You'll need a Axes window in the GUI (easiest to do in GUIDE). In r2007b to get the data to plot I needed to add variables to the GUI handle. For me
handles.variabletoplot = variabletoplot
seemed to work but I'll admit my understanding is fuzzy on this. You can use
axes(handles.axesIwanttoplot)
to set the 'current' GUI axes handle for any succeeding plot commands, such as :
plot(handles.axes3,handles.x,handles.y);
  댓글 수: 3
Craig
Craig 2012년 9월 24일
the second line should be referring to an axes handle e.g. axes3
Emanuel
Emanuel 2015년 4월 27일
Hello, I did everything you said, and I have a question. How do you extract ScopeData from the scope (i know the thing with 'save to workspace') since the workspace between GUI and the one that Simulink uses are different? I get the error: Unknown ScopeData.time and ScopeData.signals.values. Please Help!

댓글을 달려면 로그인하십시오.


Jasmine Poppick
Jasmine Poppick 2024년 4월 26일
Starting in R2024a, you can use App Designer to interactively create an app for a Simulink model, which includes the capability to easily and performantly visualize signal data in the app using the new time scope UI component.
In addition, you can:
  • Add UI components configured specifically to interact with your model, such as a simulation start/stop control and a simulation progress bar.
  • Tune model variables from the app while the simulation runs by connecting UI components to variables.
For more information, see Create App for Simulink Model.

카테고리

Help CenterFile Exchange에서 View and Analyze Simulation Results에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by