|
回复 36楼 hcharlie 的帖子
hcharlie大哥,我用龙格库塔算法写了个冲击响应谱的计算程序,对于半正选来说,最大值应该出现在71hz左右,而我的出现在35hz左右,怎么也弄不明白,
clear all
t1=0:0.00001:0.005;
n1=length(t1);
x1=zeros(1,n1);
t2=0.005:0.00001:0.015;
x2=sin(pi*(t2-0.005)/0.01);
t3=0.015:0.00001:0.02;
n3=length(t3);
x3=zeros(1,n3);
t=[t1,t2,t3];
x=[x1,x2,x3];
figure(1)
plot(t,x);
nn=length(x);
h=0.00001953125;
c=0.05;
u2=x;%输入加速度
fz=1;
y=zeros(1,nn);%响应位移
y1=zeros(1,nn);%响应速度z(t)
y2=zeros(1,nn);%响应加速度
d=[];
y2max=[];
gmax=0;
dmax=0;
i=1;
wn=2*pi*fz;
while (1)
for j=2:nn
k1=y1(j-1)*h;
l1=(-u2(j-1)-2*c*wn*y1(j-1)-wn*wn*y(j-1))*h;
k2=(y1(j-1)+0.5*l1)*h;
l2=(-(u2(j-1)+0.5*(u2(j)-u2(j-1)))-2*c*wn*(y1(j-1)+0.5*l1)-wn*wn*(y(j-1)+0.5*k1))*h;
k3=(y1(j-1)+0.5*l2)*h;
l3=(-(u2(j-1)+0.5*(u2(j)-u2(j-1)))-2*c*wn*(y1(j-1)+0.5*l2)-wn*wn*(y(j-1)+0.5*k2))*h;
k4=(y1(j-1)+l3)*h;
l4=(-u2(j)-2*c*wn*(y1(j-1)+0.5*l3)-wn*wn*(y(j-1)+k3))*h;
y(j)=y(j-1)+1.0/6.0*(k1+2*k2+2*k3+k4);
y1(j)=y1(j-1)+(l1+2*l2+2*l3+l4)/6;
y2(j)=-u2(j)-2*c*wn*y1(j)-wn*wn*y(j);%相对加速度
d(j)=y2(j)+u2(j);%绝对jiasudu
% y222(j+1)=abs(y22(j+1));
% y21(j+1)=y222(j+1)/9.81;%以g为单位
% if (abs(d)>abs(dmax))
% dmax=d;
% gmax=dmax/9.81;
% end
end
% if (i>wn)
% i=i+1;
% break;
% end
i=i+1;
fzr=round(fz);
y2max(fzr)=(max(abs(d)))/9.81;
k(fzr)=fz;
fz=wn/(2*pi);
if (fz>3000)
break;
end
% fz=fz*1.122;
wn=wn*1.122;
end
figure(2);
loglog(y2max,'-*')%对数坐标
grid on |
|