How to solve these equations using ode45?
2 views (last 30 days)
Show older comments
ok guys, I'm in a deep problem ... I need to solve equations below:
1.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155207/image.jpeg)
2.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155209/image.jpeg)
3.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155211/image.jpeg)
4.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155212/image.jpeg)
5.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155213/image.jpeg)
6.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155215/image.jpeg)
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.
0 Comments
Answers (1)
Walter Roberson
on 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.
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!