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

harman singh
harman singh 2015년 4월 1일
편집: harman singh 2015년 4월 1일
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
Torsten
Torsten 2015년 4월 1일
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.
harman singh
harman singh 2015년 4월 1일
:( tried options but getting same undesired results , its easy to learn that fortran based solver ?
Torsten
Torsten 2015년 4월 1일
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.
Torsten
Torsten 2015년 4월 1일
If you don't succeed, download "scilab" and execute the attached code.
Best wishes
Torsten.
harman singh
harman singh 2015년 4월 2일
편집: harman singh 2015년 4월 2일
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

harman singh
harman singh 2015년 3월 18일
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 .
harman singh
harman singh 2015년 3월 23일
편집: harman singh 2015년 3월 23일
"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에 대해 자세히 알아보기

질문:

2015년 3월 18일

편집:

2015년 4월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by