I need help with plotting Simulink output in Matlab
133 views (last 30 days)
Show older comments
Swarupendra Chakraborty
on 16 Sep 2020
Commented: Swarupendra Chakraborty
on 16 Sep 2020
So I am trying to plot a function from the simulink output, usingthe 'to workspace' block, but whenever I try to use the output and plat it with Matlab, the following error code appears
>> Prob_1c_ass_1_1813081
Error using timeseries/plot (line 27)
The plot method can only be used for a single timeseries object
Error in Prob_1c_ass_1_1813081 (line 2)
plot(out.tout, out.u);
My code is:
subplot(3, 1, 1)
plot(out.tout, out.u);
title('u vs t')
xlabet('t')
ylabel('u = 2sin2t')
subplot(3, 1, 2)
plot(out.tout, out.y);
title('y vs t')
xlabet('t')
ylabel('y')
subplot(3, 1, 3)
plot(out.tout, out.u, out.tout, out.y);
legend('u', 'y')
title('(u, y) vs t')
xlabet('t')
ylabel('u, y')
Could anyone help me find what I might be doing wrong?
Thanks
0 Comments
Accepted Answer
Fangjun Jiang
on 16 Sep 2020
It depends on your saving format. It looks like you have "single simulation output" checked and the format is "dataset". Press Ctrl+E and click "Data Import/Export" on the left column.
In this case, you can do plot(out.u) directly to show the plot.
To dive deep, check this value in Command Window
out.u.Time
out.u.Data
More Answers (0)
See Also
Categories
Find more on Sources 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!