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

66 ビュー (過去 30 日間)
Do
Do 2023 年 2 月 18 日
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 Center および File ExchangeProgrammatic Model Editing についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by