High amplitude in the solution of seconde order differential equation using ode 45

1 vue (au cours des 30 derniers jours)
Abhik Saha
Abhik Saha le 8 Sep 2022
Modifié(e) : Abhik Saha le 8 Sep 2022
I have a code (see below) that solve the second order differential equation. As a output it gives the position and velocity as a function of time. Now I want to plot this position vs time for several values of omega ranging from 0.1 to 1.5. But there are some cases when omega=0.48,0.5,0.85 it gives the solution of position of amplitude 10^91 (diverge solution). I guess this is due to some error but I can not find the error. For other cases of omega it gives consistent result (oscillating behaviour). How to overcome this errors for above omegas. Please help regarding this. I am new to MATLAB.
%% MAIN PROGRAM %%
t=linspace(0,10000,5000);
y0=[1 0];
omega=0.85;
[tsol, ysol]=ode45(@(t,y0) firstodefun4(t,y0,omega), t, y0, omega);
position=ysol(:,1);
velocity=ysol(:,2);
%% FUNCTION DEFINITION%%
function dy=firstodefun4(t,y0,omega)
F=1;gamma=0.01;omega0=1;
kappa=0.15;
dy=zeros(2,1);
dy(1)=y0(2);
dy(2)=2*F*sin(omega*t)-2*gamma*y0(2)-omega0^2*(1+4*kappa*sin(2*omega*t))*y0(1);
end

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by