Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function [x, t]=spring(ks,rs,startx,d,m,c,tinc,atol,vtol)
  2.  
  3. currx=startx;
  4. index=1;
  5. v=vtol+1;
  6. acc=atol+1;
  7. while ( abs(v) > vtol || abs(acc)>atol )
  8. fnet= -ks(0) * (currx- rs(0))+ ks(1)*(d-currx-rs(1)) - c * v;
  9.  
  10. acc=fnet/m;
  11. v= v + acc* tinc;
  12. currx=currx + v*tinc;
  13. tott=tott+tinc;
  14. x(index)= currx;
  15. t(index)=tott;
  16. end
  17. plot (x,t);
  18.  
  19.  
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement