Plot from workspace data in gui

3 views (last 30 days)
Loong
Loong on 2 May 2012
Answered: siyaram bhatt on 5 Jan 2017
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....

Answers (1)

siyaram bhatt
siyaram bhatt on 5 Jan 2017
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

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!