单自由度:
function [u,u1,u2]=wiltheta(m,k,c,d,e,f,p,theta,t)
n=length(p);
u=zeros(n,1);u1=zeros(n,1);u2=zeros(n,1);uu=zeros(n,1);pp=zeros(n,1);
u(1)=d;u1(1)=e;u2(1)=f;
l=6/(theta*t)^2;q=3/(theta*t);r=6/(theta*t);s=theta*t/2;
kk=k+l*m+q*c;
for i=1:n-1
pp(i)=p(i)+theta*(p(i+1)-p(i))+(l*u(i)+r*u1(i)+2*u2(i))*m+(q*u(i)+2*u1(i)+s*u2(i))*c;
uu(i)=pp(i)/kk;
u2(i+1)=u2(i)+l/theta*(uu(i)-u(i))-l*t*u1(i)-3/theta*u2(i);
u1(i+1)=u1(i)+t/2*(u2(i+1)+u2(i));
u(i+1)=u(i)+t*u1(i)+t^2/6*(u2(i+1)+2*u2(i+1));
end
end
实例:,初始时刻位移、速度、加速度均为零。以下为0.02-1时间段时程曲线。其中p=-1*[0.000508665 0.000906218 00000000.0040581 0000.0056473 0-0.000121305 -0-000000.001187971 00-0.000565749 -0-000-0-0000-0-0-0000.000469929 -0-02.34455E-05 0.0111213 0.000141692 -0.0116616 -0.0109857 00;
多自由度
function [u u1 u2]=multi_wiltheta(M,K,C,d,e,f,P,theta,t)
n=length(P(:,1));m=length(P(1,:));
u=zeros(n,m);u1=zeros(n,m);u2=zeros(n,m);uu=zeros(n,m);PP=zeros(n,m);
u(:,1)=d;u1(:,1)=e;u2(:,1)=f;
l=6/(theta*t)^2;q=3/(theta*t);r=6/(theta*t);s=theta*t/2;
KK=K+l*M+q*C;
for i=1:m-1
pp(:,i)=P(:,i)+theta*(P(:,i+1)-P(:,i))+M*(l*u(:,i)+r*u1(:,i)+2*u2(:,i))+C*(q*u(:,i)+2*u1(:,i)+s*u2(:,i));
uu(:,i)=KK\pp(:,i);
u2(:,i+1)=u2(:,i)+l/theta*(uu(:,i)-u(:,i))-l*t*u1(:,i)-3/theta*u2(:,i);
u1(:,i+1)=u1(:,i)+t/2*(u2(:,i+1)+u2(:,i));
u(:,i+1)=u(:,i)+t*u1(:,i)+t^2/6*(u2(:,i+1)+2*u2(:,i));
end
end
实例:,假设初始时刻的位移、速度、加速度均为零。以下为0.1s-2s的时程曲线。