Simulink to workspace doesn't work

My Simulink file was like that and when i want to plot the results it doesnt work
%file is untitled2.m
Mp =10;
Mj=60;
Bp = 100;
Bj = 10;
KR = 400;
sim('parachute')
subplot(4,1,1)
plot(out.Time,out.xj,out.Time,out.xp,'--')
subplot(4,1,2)
plot(out.Time,out.vj,out.Time,out.vp,'--')
subplot(4,1,3)
plot(out.Time,out.aj)
subplot(4,1,4)
plot(out.Time,out.delx)
Output workspace is like that:
How can i fix that? Thanks.

 Respuesta aceptada

madhan ravi
madhan ravi el 26 de Nov. de 2023
Double click To workspace block. Select the "Save Format" as Array.
By the way, the one you have is timeseries.
You can simply plot by doing:
plot(out.vj) % for example , you don’t need to mention time as it’s understood it has time data within as it’s timeseries

2 comentarios

Mustafa Duran
Mustafa Duran el 26 de Nov. de 2023
Thanks a lot, it worked. I have one question too. How can i set the time?
madhan ravi
madhan ravi el 26 de Nov. de 2023
Editada: madhan ravi el 26 de Nov. de 2023
Time is already integrated in timeseries. The above command is similar to doing
plot(out.vj.Time, out.vj.Data)
% when out.vj data format is Timeseries , that"s the advantage of Timeseries
When you have time, please have a look at Simulink Data Inspector. It is helpful in visualising signal without having to import to MATLAB and plotting it again just only by logging signals in Simulink.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 26 de Nov. de 2023

0 votos

3 comentarios

I closed that:
Mp=10;
Bp = 100;
Mj=60;
Bj = 10;
KR = 400;
sim('parachute')
subplot(4,1,1)
plot(t,xj,t,xp,'--')
subplot(4,1,2)
plot(t,vj,t,vp,'--')
subplot(4,1,3)
plot(t,aj)
subplot(4,1,4)
plot(t,delx)
It still doesn't work and error is like:
!! Error using plot
Data must be numeric, datetime, duration, categorical, or an array convertible to double.
Error in timeseries/plot (line 143)
p = plot(ax,Time,Data,varargin{:});
Error in parachute (line 9)
plot(t,xj,t,xp,'--')
madhan ravi
madhan ravi el 26 de Nov. de 2023
See my answer above for the data format I mentioned.
Walter Roberson
Walter Roberson el 26 de Nov. de 2023
What gets stored at the MATLAB level is likely going to be a time series .

Iniciar sesión para comentar.

Productos

Etiquetas

Preguntada:

el 26 de Nov. de 2023

Editada:

el 26 de Nov. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by