line 15 does not work

1 次查看(过去 30 天)
Mlee
Mlee 2021-4-8
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by