声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

声振论坛 展示 基础理论 查看内容

单自由度振动动画

2012-10-19 11:00| 发布者: aspen| 查看: 877| 评论: 0|原作者: TNC|来自: 振动论坛

摘要: %Tegning af sdof oscillator clear all; %System data m=1.0; zeta=0.01; omega0=1.0; Dt=1.0; f0=1.0; x0=0.0; dotx0=0.0; xmax=sqrt(x0^2+(dotx0/omega0)^2)+min(); omegad=omega0*sqrt(1-zeta^2); dt0=0.1* ...
  1. %Tegning af sdof oscillator
  2. clear all;
  3. %System data
  4. m=1.0; zeta=0.01; omega0=1.0; Dt=1.0; f0=1.0; x0=0.0; dotx0=0.0;
  5. xmax=sqrt(x0^2+(dotx0/omega0)^2)+min([0.5*abs(f0)*Dt/(m*omega0) f0/omega0^2]);
  6. omegad=omega0*sqrt(1-zeta^2); dt0=0.1*pi/omega0; nstep=500;
  7. a=0.70; b=0.70; r=0.35*a; fact=0.50/xmax;
  8. xf0=0.5*[0 -a 0 a 0]'; yf0=[0 -b/4 -b/2 -3*b/4 -b]';
  9. xd1=0.5*[-a -a a a]'; yd1=[-6*b 0 0 -6*b]';
  10. xd2=0.5*[-0.8*a 0.8*a]'; yd2=[-3*b -3*b]';
  11. xf0=[xf0; xf0; xf0; xf0; xf0; xf0];
  12. yf0=[yf0; -b+yf0; -2*b+yf0; -3*b+yf0; -4*b+yf0; -5*b+yf0];
  13. xf=[0; xf0; 0]; xSQ=[-a 5*a 5*a -a -a]'; ySQ=[0 0 -2*r -2*r 0]';
  14. xH=[-2000 2000]'; yH=[0 0]'; xx=x0; tt=0;
  15. set(gcf,'DoubleBuffer','on');
  16. i=1; t=i*dt0; t0=min([t Dt]); t1=t-t0;
  17. h=exp(-zeta*omega0*t)*sin(omegad*t)/(m*omegad);
  18. doth=exp(-zeta*omega0*t)*(cos(omegad*t)-zeta*omega0/omegad*sin(omegad*t))/m;
  19. H=(1/m-doth-2*zeta*omega0*h)/omega0^2;
  20. h1=exp(-zeta*omega0*t1)*sin(omegad*t1)/(m*omegad);
  21. doth1=exp(-zeta*omega0*t1)*(cos(omegad*t1)-zeta*omega0/omegad*sin(omegad*t1))/m;
  22. H1=(1/m-doth1-2*zeta*omega0*h1)/omega0^2;
  23. if t>Dt
  24. t2=t-Dt; h2=exp(-zeta*omega0*t2)*sin(omegad*t2)/(m*omegad);
  25. doth2=exp(-zeta*omega0*t2)*(cos(omegad*t2)-zeta*omega0/omegad*sin(omegad*t2))/m;
  26. H2=(1/m-doth2-2*zeta*omega0*h2)/omega0^2;
  27. else H2=0; end
  28. x=-f0*H2+f0*(t0/m+h1-h+2*zeta*omega0*(H1-H))/(Dt*omega0^2);
  29. x=x+exp(-zeta*omega0*t)*(x0*cos(omegad*t)+(dotx0+zeta*omega0*x0)*sin(omegad*t)/omegad);
  30. tt=[tt; t]; xx=[xx; x]; x=fact*x;
  31. yf=[0; -2*b+(1+x)*yf0; -6*b+(1+x)*yf0(size(yf0,1))];
  32. clf; figure(1); subplot(2,1,1); h1=plot(xH,yH,'r'); hold on
  33. h2=plot(xH,yH-6*b+yf0(size(yf0,1))-r,'k');
  34. h3=plot(xf,yf,'r'); h4=plot(4*a+xd1,-3*b+yd1,'r');
  35. h5=plot(4*a*[1 1]',-3*b*[0 1]','r'); hej=yf(size(yf,1));
  36. h6=plot(4*a+xd2,(-7*b+yf(size(yf,1))-hej)*ones(2,1),'r');
  37. h7=plot(4*a*[1 1]',[-7*b+yf(size(yf,1))-hej yf(size(yf,1))]','r');
  38. h8=plot(xSQ,yf(size(yf,1))+ySQ,'r'); hold off
  39. axis([-2 5 -10*b+(1+fact*x0)*yf0(size(yf0,1))-2*r r]);
  40. subplot(2,1,2); h9=plot(xH,yH,'k'); hold on;
  41. h10=plot(tt,-xx,'r'); hold off; axis([ 0 nstep*dt0 -xmax xmax])
  42. % start loop
  43. for i=1:nstep
  44. t=i*dt0; t0=min([t Dt]); t1=t-t0;
  45. h=exp(-zeta*omega0*t)*sin(omegad*t)/(m*omegad);
  46. doth=exp(-zeta*omega0*t)*(cos(omegad*t)-zeta*omega0/omegad*sin(omegad*t))/m;
  47. H=(1/m-doth-2*zeta*omega0*h)/omega0^2;
  48. h1=exp(-zeta*omega0*t1)*sin(omegad*t1)/(m*omegad);
  49. doth1=exp(-zeta*omega0*t1)*(cos(omegad*t1)-zeta*omega0/omegad*sin(omegad*t1))/m;
  50. H1=(1/m-doth1-2*zeta*omega0*h1)/omega0^2;
  51. if t>Dt
  52. t2=t-Dt; h2=exp(-zeta*omega0*t2)*sin(omegad*t2)/(m*omegad);
  53. doth2=exp(-zeta*omega0*t2)*(cos(omegad*t2)-zeta*omega0/omegad*sin(omegad*t2))/m;
  54. H2=(1/m-doth2-2*zeta*omega0*h2)/omega0^2;
  55. else H2=0; end
  56. x=-f0*H2+f0*(t0/m+h1-h+2*zeta*omega0*(H1-H))/(Dt*omega0^2);
  57. x=x+exp(-zeta*omega0*t)*(x0*cos(omegad*t)+(dotx0+zeta*omega0*x0)*sin(omegad*t)/omegad);
  58. tt=[tt;t]; xx=[xx;x]; x=fact*x;
  59. yf=[0; -2*b+(1+x)*yf0; -6*b+(1+x)*yf0(size(yf0,1))];
  60. set(h3,'Xdata',xf); set(h3,'Ydata',yf);
  61. set(h4,'Xdata',4*a+xd1); set(h4,'Ydata',-3*b+yd1);
  62. set(h5,'Xdata',4*a*[1 1]'); set(h5,'Ydata',-3*b*[0 1]');
  63. set(h6,'Xdata',4*a+xd2); set(h6,'Ydata',(-7*b+yf(size(yf,1))-hej)*ones(2,1));
  64. set(h7,'Xdata',4*a*[1 1]'); set(h7,'Ydata',[-7*b+yf(size(yf,1))-hej yf(size(yf,1))]');
  65. set(h8,'Xdata',xSQ); set(h8,'Ydata',yf(size(yf,1))+ySQ);
  66. set(h10,'Xdata',tt); set(h10,'Ydata',-xx); pause(0.1)
  67. end
复制代码

[ 本帖最后由 ChaChing 于 2010-8-12 00:36 编辑 ]

最新评论

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-24 18:57 , Processed in 0.037348 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部