Is my ODE 45 function right?

Hello all, I am trying to solve the response of structure under tri-directional earthquake excitations using ODE 45. I have attached the code. I was wondering if my code is correct or not because the result is not good.
F=zeros(6001,3); % Earthquake excitation
F(:,1)=9.8*load('D:\CompatibleTH and Program\TH-RG160\LoValley_H1_compRG_acc.txt'); % 1st input point, 1st direction
F(:,2)=9.8*load('D:\CompatibleTH and Program\TH-RG160\LoValley_H2_compRG_sf_acc.txt'); % 1st input point, 2nd direction
F(:,3)=9.8*load('D:\CompatibleTH and Program\TH-RG160\LoValley_V_compRG_sf_acc.txt');% 1st input point, 3rd direction
global w a
for v=1:3
w=omega(v,v) % omega is a 3x3 matrix which has been solved before
for b=1:3
a=F(:,b);
[t, y]=ode45(@my_struc_fun_lanlan,[0:0.005:30],[0 0]);
q(:,b+3*(v-1))=y(:,1);
end
end
The defined function is as follows:
function [ f ] = my_struc_fun_lanlan( t,y)
global w a
gt=[0:0.005:30]';
A=[0,1;-w^2,-2*0.05*w];
g1=0;
g2=interp1(gt,a,t); % interprate the input data at time t
g=[g1;g2];
f=A*y-g;
% f=zeros(2,1);
% f(1)=y(2);
% f(2)=-w^2*y(1)-2*0.05*w*y(2)-g2;
end
ANY help would be very appreciated. Thank you.

댓글 수: 3

darova
darova 2019년 11월 19일
Where are original equations? Can you attach/show?
Rui Wang
Rui Wang 2019년 11월 23일
Hi Darove,
The original DE is attached. Thank you.
darova
darova 2019년 11월 23일
Looks ok. WHy do you think the result is incorrect?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Seismology에 대해 자세히 알아보기

질문:

2019년 11월 19일

댓글:

2019년 11월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by