Want to limit the lines of output. (for example, output after every 1000 iterations)
Mostrar comentarios más antiguos
time = 0;
tstop=input('enter tstop now');
m=input('enter value of m now');
k= input('enter value of k now');
b= input('enter b value now');
dt=input(' enter value of time step now');
nstep=input('enter value of nstep');
pos=input('enter starting position now');
vel=input('enter starting velocity now');
i=1;
j=1;
while time < tstop
t(i) = time;
xdot(i) = vel;
x(i) = pos;
acc= -(k/m)*pos -(b/m)*vel;
x2dot(i)=acc;
vel = vel + acc*dt;
pos = pos + vel*dt;
time = time+dt;
i=i+1;
end
out=[t',x2dot',xdot',x']
1 comentario
Image Analyst
el 27 de Nov. de 2011
Why is "out" outside your loop? Do you want to break out of the loop when i = 1000? If you want to continue the loop you should put it inside the loop like Sven showed you.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!