ode 45 - different results with different coordinate set
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Jan
2018년 9월 10일
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!