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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Seismology finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 19 Nov. 2019

Kommentiert:

am 23 Nov. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by