I need help with plotting Simulink output in Matlab
149 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Fangjun Jiang
2020-9-16
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!