用MATLAB计算受迫振动程序
clear all %sy196.m
xc=dsolve('D2x+2*b*Dx+w0^2*x+h*cos(wc*t)=0','Dx(0)=0,x(0)=A','t');
w0=0.3*pi; b=0.1;
A=0.2; h=0.4;
t=linspace(0,100,1000);
i=1;
for k=0.1:0.01:2.5 % k=wc/w0 驱动频率与固有频率之比
r(i)=k;
wc=k*w0;
xc1=eval(xc);
a(i)=max(real(xc1));
i=i+1;
end
subplot(2,1,1) %画受迫振动振幅与频率比之间的关系曲线
plot(r,a,’.-r’)
subplot(2,1,2) %画受迫振动曲线
plot(t,xc1,'-b',t,0,'-r')
1