How to solve an ODE (4th order) by using ode23s?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello guys,
actually I am trying to solve the following ODE by using ode23s. Unfortunately I don't really know how to do it.
The ode is given as: bo(t)*y + b1(t)*y' + b2(t)*y'' + b3(t)*y''' + b4(t)*y''' = ao(t)*cst . (Those derivatives should be marked with dots 'cause, they're all time-derivatives, eg. y' = dy/dt, y'' = d2y/dt2 etc. The parameters bo, b1, ..., b4 and ao are given as functions. 'cst' is a constant.
First, I transformed this equation into a system of ODEs, what leads me to the following function:
function [dy] = odetest(y,cst,ao,bo,b1,b2,b3,b4)
dy = [ y(2); ...
y(3); ...
y(4); ...
(-b1*y(2) + ao*cst - b2*y(3) - b3*y(4) + bo*y(1))*(1/(b4)) ];
end
So ... to simplify the procedure (and as a first approximation) I want to hold the time-dependent parameters ao, bo, b1, ... b4 constant for each time step.
And now the problem starts: I don't know how to put this function in ode23s that it could be solved for an arbitrary timestep, because the 'time' is somehow missing in my ODE-system. Maybe I made a kind of mistake in the transformation of the time-derivatives ...
I guessed that the solution has to be something like
% file where the Ode has to be solved
% Loop for each time-step
for i=1:number_timesteps
time0 = i-1;
time = i;
ao = function_ao(i); % function of parameter a, which is now constant in each timestep
bo = function_bo(i);
b1 = function_b1(i);
b2 = function_b2(i);
b3 = function_b3(i);
b4 = function_b4(i);
y = value1; % initial conditions for y
dy = value2;
ddy = value3;
dddy = value4;
cst = value5; % value of cst in the actual timestep
[T, Y] = ode23s(@odetest, [y; dy; ddy; dddy], cst, ao, bo, b1, b2, b3, b4 ); % the arguments are the inital conditions, parameters ao, bo, ...
plot(T,Y);
end
But ... I don't really understand where to put the time-step into ode23s ... (And I don't know either how to solve the problem if the parameters ao, bo, b1, ..., b4 change during one time-step, so that ode23s has to use their functions ...
It would be great if someone can help me. Thank you in advance, netorha
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!