Borrar filtros
Borrar filtros

Make Ode45 return non trivial solution

2 visualizaciones (últimos 30 días)
Hello there, as the title says: I'm trying to solve a problem of differential equations using ode45. The second order problem is in this code:
Tspan= 0 : 0.01 : 10;
y0=[ 0 ;0 ];
Y=zeros( 4 , numel( Tspan ) );
for ( i=1 : 4)
f= @(t,y) [ y(2); (1/a) * (F(i)*sin(fu*2*pi*t) - b*y(2) - c*y(1) ) ]
[time,answer]=ode45( f, [ Tspan ] , y0 );
Y( i , : ) = answer( : , 1 );
end
So my differential equation problem is: a*ddy+b*dy+c*y=F(i), where ddy is the second derivative and dy is the first derivative.
F is a 4x1 vector, with only one entry. Now the problem is, that ode45 returns agood solution for only one iteration, which is the one where the F entry is not equal to 0. But for the other 3 iterations the solution for y and dy is set to be always 0 at any time. Yes, y=0 solves the equation. But it's not what I hoped to find.
Is there an option for ode45 to just return non trivial solutions?
Thank you

Respuesta aceptada

James Tursa
James Tursa el 3 de Dic. de 2020
If F(i)=0 and y0=0 and dy0=0, then there is no driving acceleration away from the y(t)=0 solution. I.e., y(t)=0 is the solution ... there isn't any "other" solution. If you want other solutions then you need to provide different initial conditions. E.g., maybe small non-zero values of y0 and dy0.
  1 comentario
Leonardo Alessandro Cabral Igler
Leonardo Alessandro Cabral Igler el 4 de Dic. de 2020
Thank you very much, turns out I focused too much on this differential equation, that I forgot that I still have to multiplicate the solution Y with a Matrix to get the answer to my actual problem set.
That way I get the solution I want, which is non zero for the other three components.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by