line 15 does not work

1 visualización (últimos 30 días)
Mlee
Mlee el 8 de Abr. de 2021
Respondida: David Hill el 8 de Abr. de 2021
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 comentario
Steven Lord
Steven Lord el 8 de Abr. de 2021
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.

Iniciar sesión para comentar.

Respuesta aceptada

David Hill
David Hill el 8 de Abr. de 2021
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.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by