Make Ode45 return non trivial solution

1 回表示 (過去 30 日間)
Leonardo Alessandro Cabral Igler
Leonardo Alessandro Cabral Igler 2020 年 12 月 3 日
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
Leonardo Alessandro Cabral Igler 2020 年 12 月 4 日
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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by