Solving ODE with conditional statements

Hi,
I have a question here regarding ODE modeling in matlab. I was wondering if I can create an ODE model with conditional statements.
For example: dx/dt = 1/7 dy/dt = 1/3 dy/dt = 0 if x & y are both integers
If it is possible, what would be the command/coding script for dy/dt in this case?
Thanks!

답변 (2개)

Jan
Jan 2013년 8월 25일
편집: Jan 2013년 8월 25일

0 개 추천

An integration requires a smooth function. For such discontinuities the stepsize controller of Matlab's integrators get serious troubles, see e.g. http://www.mathworks.com/matlabcentral/answers/59582#answer_72047 .
The integrator controls the stepsize based on the locale discretization error. Therefore it is very unlikely, that the variables are exactly integer. Then notice, that x and y will have integer values for an infinitely interval only. Therefore changing the derivative there, this cannot change the result of the integration.
G
G 2013년 8월 25일
편집: G 2013년 8월 25일

0 개 추천

For example if:
dx/dt = 1/2,
dy/dt = 1/4,
dy/dt = 0 if both x and y are intergers
at t = 0 [x,y] = [0,0]
Therefore, at t = 4, x = 2 and y = 1
So you're saying that MatLab's ODE Solver does not have the capability of drawing on a true/false mechanism to determine if both x and y are integers for the stepwise model of dy/dt?

카테고리

질문:

G
G
2013년 8월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by