Borrar filtros
Borrar filtros

Solution of ODE in different time intervals

3 visualizaciones (últimos 30 días)
maro
maro el 28 de Mzo. de 2013
I want to solve ODE as a function over three different intervals [0,1],[1,1.2] and [1.2,3].
My function to solve my ODE is "solveODE" as following:
function [x, tinter, xinter] = solveODE(xdot, T, t0, ...
x0, u)
[tinter,xinter] = ode45(xdot, ...
[t0, t0+T], x0,u);
x = xinter(size(xinter,1),:);
end
where: "xdot" is my ODE function here k1 is constant has different valuesaccording to each of three intervals.
ODE function to be solved is as following:
function xprime = xdot(t, x, u, T)
xprime =[x(2);...
-k1*x(2)+k4*u(1)];
end
  2 comentarios
Jan
Jan el 28 de Mzo. de 2013
Editada: Jan el 28 de Mzo. de 2013
What is your question? Which problems do you observe? How do you call solveODE?
maro
maro el 29 de Mzo. de 2013
y file is complicated but I will make it simpler. if I have this simple ODE function:
function xdot=m(x,t)
xdot=k1*x(1);
end
Where k1 is a constant changing according to the time intervals (say for [0,1] k1=1, for [1,3] k1=2, for [3,10] k1=3).
I want to solve that ODE with ode45 command as a function over the different three intervals for example:
function [x, tinter, xinter]=solveODE(xdot,T,t0,x0)
[tinter,xinter] = ode45(system,[t0, t0+T], x0, options, u);
x = xinter(size(xinter,1),:);
end
where t0 change every iteration.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by