How to solve these equations using ode45?

1 Ansicht (letzte 30 Tage)
babak dindar safa
babak dindar safa am 28 Jul. 2016
Beantwortet: Walter Roberson am 28 Jul. 2016
ok guys, I'm in a deep problem ... I need to solve equations below:
1.
2.
3.
4.
5.
6.
I have used ode45 before, but this one i can't figure out!
here is the equation that returns nothing :
clear, clc, close all;
%Load Initial Data
ACC=load('15 Imperial Valley El Centro 180.txt');
ag=9.8.*ACC(:,1); %m/s^2 horizontal ground acceleration
dt=0.01; %s ground acceleration time step
N=length(ag);
T=(N-1)*dt; %s ground acceleration duration
t=0:dt:T; % time vector
%Define Factors
dxdata = cumtrapz(t, ag);
xdata = cumtrapz(t, dxdata);
A = 1;
beta = 0.1;
gamma = 0.9;
n = 2;
mass = 10; %in g
Fy = 2.86; %in KN
Uy = 0.111; %in m
a = 0.1;
c = 0;
p = 2;
Ini_dx = dxdata(1);
Ini_x = xdata(1);
Ini_nou = 0;
Ini_eta = 0;
Ini_A = 1;
delta_nou = 0;
delta_eta = 0;
delta_psi = 0;
delta_A = 0;
Ini_zeta = 0;
psi = 0;
lambda = 0;
factor_q = 1;
factor_omega = sqrt(Fy/(mass * Uy));
[t,y] = ode45(@znew,t,[0 0 0],[],A,beta,gamma,n,mass,a,p,dxdata,xdata,Ini_nou,Ini_eta,Ini_A,delta_nou,delta_eta,delta_psi,delta_A,Ini_zeta,psi,lambda,factor_q,factor_omega);
z = y(:,2);
plot(t,z);
function out = znew(t,y,A,beta,gamma,n,mass,a,p,dxdata,xdata,Ini_nou,Ini_eta,Ini_A,delta_nou,delta_eta,delta_psi,delta_A,Ini_zeta,psi,lambda,factor_q,factor_omega)
dut = interp1(dxdata,t,'spline');
ut = interp1(xdata,t,'spline');
z = y(2);
out = zeros(3,1);
epsilon = (1-a) * (factor_omega^2) * z * ut;
out(1) = epsilon;
noue = Ini_nou + delta_nou * epsilon;
Ae = Ini_A - delta_A * epsilon;
etae = Ini_eta + delta_eta * epsilon;
zu = (1/(noue*(beta+gamma)))^(1/n);
zeta1 = Ini_zeta * (1-exp(-p*epsilon));
zeta2 = (psi + delta_psi * epsilon)*(lambda + zeta1);
hzt = 1-zeta1*exp(-(((z * sign(dut)) - factor_q*zu)^2)/zeta2);
dz = hzt * (Ae*dut - noue*(beta*abs(dut)*(abs(z)^(n-1))*z + gamma*dut*(abs(z)^n)))/etae;
out(2) = z;
out(3) = dz;
end
would appreciate some help guys ... not really good with ode45 :)
thanks in advance.

Antworten (1)

Walter Roberson
Walter Roberson am 28 Jul. 2016
You are using an old syntax for ode45 that has not been documented for a decade. Please parameterize your function instead of counting on ode45 passing all those extra variables in.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by