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;endout=[t',x2dot',xdot',x']
MATLAB: Want to limit the lines of output. (for example, output after every 1000 iterations)
number of iterations
Best Answer