Plot from workspace data in gui

3 次查看(过去 30 天)
Loong
Loong 2012-5-2
I would like to get the results from my simulink model and plot in the GUI, but I facing problem to getting data from workspace. In my simulink model, i have save my simulation data to base workspace using "to workspace" block. I just want a simple gui that i press on push button, data that i save to base workspace can be plot out.
I have tried below codes:
1) plot(x,y); (error show undefined variables, but x and y already save in the workspace)
2)x=evalin('base','x'); y=evalin('base','y'); plot(x,y); (error show it not enough input argument )
But still cannot. I think it should very simple.
Please help....I am new in matlab....

回答(1 个)

siyaram bhatt
siyaram bhatt 2017-1-5
You can use scope block in Simulink for Workspace in Matlab. In scope under logging you can choose "log to workspace" option. Take this option for GUI.
Then write in Matlab script:
axes(handles.plot1); % (plot1 is the name of axes)
plot(Scopedata.time, Scopedata.signals.values);
ing

类别

Help CenterFile Exchange 中查找有关 Interactive Model Editing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by