ode 45 - different results with different coordinate set
2 views (last 30 days)
Show older comments
I am solving system of next equations:
function f=fun(z,p)
R=1; sig=1; beta=1;
f=zeros(4,1);
f(1)=-32*1*beta/(R.^4*p(1));
f(2)=(-(2-sig)*8*f(1)/(sig.*R)-f(1)*p(2))/p(1);
f(3)=(-p(2)*f(2)+(2-sig)*(-8*f(2)/R-8*f(1)/(R.*R*p(1)))/sig-f(1)*p(3))/p(1);
%f(4)=(-f(2)*p(3)-f(3)*p(2)+(2-sig)*8*(-f(3)/R-(f(2)/p(1)-p(2)*f(1))/(p(1).*p(1)*R.*R))/sig -f(1)*p(4))/p(1);
f(4)=(-f(2)*p(3)-f(3)*p(2)+(2-sig)*8*(-f(3)/R-f(2)/p(1)+p(2)*f(1)/(p(1).*p(1)))/(sig.*R.*R) -f(1)*p(4))/p(1);
with ode45 function. When I call it with this command:
[zv,pv]=ode45(@fun,[1 0],[1;0;0;0])
where my coordinate is going from 0 to 1, and appropriate initial conditions at coordinate 1 are: 1;0;0;0 I got good results. But when I change my code where I am calling my function with this one:
[zv,pv]=ode45(@fun,[0 1],[7.5;0;0;0])
where my coordinate is going from 0 to 1, and appropriate initial conditions at coordinate zero are 7.5;0;0;0 I got something what is not ok and not even similar with the first results, where I plot this:
p4uk=pv(:,1)+0.1*pv(:,2)+0.1*0.1*pv(:,3)+0.1*0.1*0.1*pv(:,4);
plot(zv,p4uk);
Why is this happening when I tried to get results for the same case, just from different sides?
1 Comment
Jan
on 10 Sep 2018
where my coordinate is going from 0 to 1
In the line [zv,pv]=ode45(@fun,[1 0],[1;0;0;0]) the time goes from 1 backward to 0. Do you mean this time with "coordinate from 0 to 1"?
You integrate a function one time over the time from 1 to 0 starting from [1,0,0,0] and another time over 0 to 1 starting from [7.5,0,0,0]. Of course you get completely different solutions. Why do you consider the second one as "not okay"? Of course the result is correct numerically, so I assume your expectations are the problem.
Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!