How to use wrapTo2Pi in user defined function which will be solved by ode45?

I have systems of ODE which is
function dxdt = dyn(t,x)
dxdt=[((-x(2))/b)+(x(1)*(x(3)+x(2))/2))
wrapTo2Pi(a*x(1))
(d*x(1)*x(3))];
To solve this system;
[T,X] = ode45(@dyn, [0:0.0005:90], x0);
When I work on this problem, wrapTo2Pi function did not work. For x(2), I can see numbers which are bigger than 2*pi. Is there any way to use wrapTo2Pi in this format?
Note: These ODE system, initial condition and time properties are only sample to show my problem.

댓글 수: 1

I'd guess it'll foul things up, but you can try wrapping each x inside the call; you've only done one of three here...

댓글을 달려면 로그인하십시오.

 채택된 답변

Torsten
Torsten 2017년 10월 10일
편집: dpb 2017년 10월 10일
You solve dx(2)/dt = wrapTo2Pi(a*x(1)), not x(2)-wrapTo2Pi(a*x(1))=0. So of course, x(2) can become larger than 2*pi.
Best wishes
Torsten.

댓글 수: 1

dpb
dpb 2017년 10월 10일
편집: dpb 2017년 10월 10일
I'm guessing trying to wrap phase during the solution will wreak havok with the discontinuities introduced--probably better solution would be to do the solution and then unwrap phase when done. Can always try and see what happens, of course...
PS. Added the missing capital T in the wrapTo2Pi() functions, Torsten...dpb

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2017년 10월 10일
편집: Jan 2017년 10월 10일
ODE45 cannot handle discontinuities. The step size controller will either stop the integration with an error or even worse reduce the step size until the discontinuity is concealed by rounding errors. Then the result can be dominated by rounding errors. See http://www.mathworks.com/matlabcentral/answers/59582#answer_72047.
I can see numbers which are bigger than 2*pi
This is not clear enough: Which values are bigger? While dxdt(2) cannot be larger, x(2) can of course.

질문:

2017년 10월 9일

편집:

Jan
2017년 10월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by