MATLAB Answers

line 15 does not work

14 views (last 30 days)
Mlee on 8 Apr 2021 at 18:10
Answered: David Hill on 8 Apr 2021 at 19:10
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))];
y =step(sys, t );
plot( t,y(:,1), '-',t,y(:,2),':');
ttl=sprintf('Response with b = %.0f',b);
  1 Comment
Steven Lord
Steven Lord on 8 Apr 2021 at 18:19
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.

Sign in to comment.

Accepted Answer

David Hill
David Hill on 8 Apr 2021 at 19:10
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.

More Answers (0)





Community Treasure Hunt

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

Start Hunting!

Translated by