odes with variable coefficients

i am solving system of linear ode with time varying (gaussian )coefficients using standard ode45 approach but i am not getting desired results ,do i need to make some changes to accomodate time variartion of coefficients ? below i copy pasted from my m file along with command
% function dy=tarak(t,y)
g0=.1;
t0=200;
s=90;
g=g0*exp(-((t-t0)/s).^2);%time varying gaussian coefficient "g"
G=sqrt(10);
dy=zeros(5,1);
dy(1)=-2*2*y(1)+1i*G*conj(y(3))+1i*g*conj(y(4))-1i*G*y(3)-1i*conj(g)*y(4);
dy(2)=2*y(1)+1i*G*y(3)-1i*G*conj(y(3));
dy(3)=-2*y(3)+1i*G*y(2)+1i*g*conj(y(5))-1i*G*y(1);
dy(4)=-2*y(4)+1i*G*y(5)+1i*g*(1-y(1)-y(2))-1i*g*y(1);
dy(5)=1i*G*y(4)-1i*g*conj(y(3));
Command [T,Y] = ode45(@tarak,[0 ,500],[0 0 0 0 0]);
Thanks for your time

 采纳的回答

Torsten
Torsten 2015-4-1

0 个投票

Here are the results.
Best wishes
Torsten.

6 个评论

Thanks Torsten!!! ,these are the result i was looking for . y(1),y(2),y(3) all positive with their sum equal to 1 , but i don't know why i am getting negative values for these ? can you please share the M file you created and commands ,so that i can know my fault .thanks again blessings !
harman
I used another FORTRAN-based solver, but try strengthening the tolerances for ODE45
options = odeset('RelTol',1e-8,'AbsTol',1e-8); [T,Y] = ode45(@tarak,[0 500],[0 0 1 0 0 0 0 0 0],options);
Best wishes
Torsten.
:( tried options but getting same undesired results , its easy to learn that fortran based solver ?
First I'd try another MATLAB Integrator (e.g. ODE15s or ODE113).
If this does not work, let's take a look at your MATLAB code to see whether something is wrong.
Best wishes
Torsten.
If you don't succeed, download "scilab" and execute the attached code.
Best wishes
Torsten.
hi Torsten , you were right by strengthening the tolerance level i am getting the much required positive results .
options = odeset('AbsTol', 1e-12); [T,Y] = ode45(@tarak, [0, 500], [0 0 1 0 0 0 0 0 0], options);
Thanks for your help .

请先登录,再进行评论。

更多回答(1 个)

Torsten
Torsten 2015-3-18

0 个投票

Formally, everything looks fine. Of course we don't know if your underlying equations are correct.
Are you sure ODE45 can handle complex-valued ODEs ?
Best wishes
Torsten.

3 个评论

Thanks Torsten for reply , i will recheck and rederive my equations ,i feel matlab ode solvers have no issues with complex valve equations .
thanks again .
"Are you sure ODE45 can handle complex-valued ODEs" ? hi i found this
The ODE solvers in MATLAB 5 (R12) and later releases properly handle complex valued systems."MathWorks Support Team on 26 Jul 2010"
hi Torsten, i have transformed my equations into real form
now these are 9 equations
dy(1)=-2*2*y(1)+2*G*y(5)+2*g*y(7);
dy(2)=2*y(1)-2*G*y(5);
dy(3)=2*y(1)-2*g*y(7);
dy(4)=-2*y(4)+g*y(9);
dy(5)=-2*y(5)+G*(y(2)-y(1))+g*y(8);
dy(6)=-2*y(6)-G*y(9);
dy(7)=-2*y(7)+g*(y(3)-y(1))+G*y(8);
dy(8)=-G*y(7)-g*y(5);
dy(9)=G*y(6)-g*y(4);
where where Coefficient G =3.16
and g = 0.1*exp(-((t-200)/90).^2) % gaussian time dependent coefficient " g"
t= time 0:500 , Initial Condition [0 0 1 0 0 0 0 0 0]
can you pls try ode45 on above equations and copy paste results here . thanks

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by