using scope in Matlab Simulink to display when input's value changes

조회 수: 66 (최근 30일)
Do
Do 2023년 2월 18일
댓글: Sulaymon Eshkabilov 2023년 2월 20일
How do display all output in one scope when input's value chance:
EX:
Transfer of system is 1/(s^2+a*s+1) with a = {1:1:10}
a is declared in matlab then it is used for Simulink

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 18일
It is a very intersting exercise. There are a few different ways to get simulation results for different values of a as defined in the exercise. Here are a couple of ways:
(1) Everything in Simulink. The variable "a" is also defined inside Simulink as a look up table via Model Explorer options. All 10 simulation results for a = [1 2 3 .. 10] are stored inside one scope block.
% sim('VerA_Loop.slx') % All simulation results are stored in one simulink
% S = sim("VerA_Loop.slx"); % ALL Sim results are stored in one scope
% for a = 1:10
% plot(S.Sout.time, S.Sout.signals(a).values)
% hold all
% L{a} = ['a = ' num2str(a)];
% legend(L{:})
% end
(2) Simulation is called from MATLAB and results are obtained/augmented in MATLAB (not exactly as given in the assignment)
for a = 1:10
S=sim("VerB_Loop.slx");
plot(S.Out(:,1),S.Out(:,2))
hold all
L{a} = ['a = ' num2str(a)];
legend(L{:})
SimOUT{a} = S.Out; % ALL Sim results are stored
end
  댓글 수: 2
Do
Do 2023년 2월 20일
Great! Thank for your help!
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 20일
Most welcome! Glad to help. So you accept the suggested solution :)

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

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by