Make Ode45 return non trivial solution

조회 수: 1 (최근 30일)
Leonardo Alessandro Cabral Igler
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

채택된 답변

James Tursa
James Tursa 2020년 12월 3일
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
Leonardo Alessandro Cabral Igler
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by