clear all, close all
m1 = 10;
m2 = 350;
kw = 500000;
ks = 10000;
Bd = [ 1000 2000 3000 4000 ];
t = 0:0.01:2;
for i = 1:4
b = Bd(i);
num = kw*b/(m1*m2)*[1 ks/b];
den =[1 (b/m1+b/m2) (ks/m1+ks/m2+kw/m1) (kw*b/(m1*m2)) (kw*ks/(m1*m2))];
sys=tf(num,den);
y =step(sys, t );
subplot(2,2,i);
plot( t,y(:,1), '-',t,y(:,2),':');
legend('wheel','car')
ttl=sprintf('Response with b = %.0f',b);
title(ttl);
end

1 件のコメント

Steven Lord
Steven Lord 2021 年 4 月 8 日
Which line is line 15? Don't make us guess or count, tell us.
What does "does not work" mean?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support using the Contact Support link on the Support section of the MathWorks website so we can investigate.

サインインしてコメントする。

 採用された回答

David Hill
David Hill 2021 年 4 月 8 日

0 投票

If you inspect your variables before plotting, you will find that y is a single column.
plot(t,y,'-');%this will work in your current code, but you were expecting plots for wheel and car and are only getting one.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

製品

リリース

R2018a

タグ

質問済み:

2021 年 4 月 8 日

回答済み:

2021 年 4 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by