How to output a tout from Simulink space to Matlab so that it reads the value to us?

조회 수: 67 (최근 30일)
During the simulink simulation, I have a problem with the derived "tout" in m-matlab file gives me an error "Unrecognized function or variable 'tout'." but tout is in the workspace in ANS, I wanted to draw the graphs in matlab and I derived "OUT" from the simulink, and "tout" from the simulation. Please help me and best regards.
sim('cw_6_silnik') % simulink file name
Unable to find system or file 'cw_6_silnik'.
t=tout;
delta=yout(:,1);
n=yout(:,2);
T_e=yout(:,3);
T_a=yout(:,4);
P_e=pi/30*T_e.*n;
figure(1)
plot(t,delta,'b'), grid on
xlabel('t [s]')
ylabel ('\delta [deg]')

답변 (2개)

Askic V
Askic V 2023년 5월 23일
편집: Askic V 2023년 5월 23일
Hi @Krzysztof, when I want to access variables from simulink, plot them etc.
I use to Workspace block in simulink and choose Array option, just like shown in the image below.
% Check if out variable is accessible in Workspace
whos out
% Plot
plot(out.time, out.output);
hold on:
plot(out.time, out.input);
hold off;

Krzysztof
Krzysztof 2023년 5월 23일
sim('cw_6_silnik')
whos out
plot(out.time, out.simout);
hold on:
plot(out.time, out.simout1);
hold off;
data from out "to workspace" appears but I can't process it further
  댓글 수: 4
Krzysztof
Krzysztof 2023년 5월 23일
@Askic V thanks for helping me find a solution. Best regards.
Askic V
Askic V 2023년 5월 23일
No problem. So it seems this is changed in newer Simulink versions. In old version (2021a at least) the output variable was
'Simulink.SimulationOutput'

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by