I need help with plotting Simulink output in Matlab

153 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 16 de Sept. de 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

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by