How to use wrapTo2Pi in user defined function which will be solved by ode45?
Mostrar comentarios más antiguos
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 comentario
dpb
el 9 de Oct. de 2017
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...
Respuesta aceptada
Más respuestas (1)
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.
Categorías
Más información sobre Lengths and Angles en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!