Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Using 'if' to evaluate independent variable on DAE
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello Be 't' the independent variable
I can use if to evaluate 't' on ODE:
function f=ODE(t,y)
if t<10 a=10; else a=0; end
f=a;
end
[t,y]=ode15s('ODE',[0,100],1)
I can use if to evaluate 't' on DAE: When the algebraic equation don't depend on the result from if
function f=DAE(t,y)
if t>10 a=0; else a=10; end
b=y(2)+1;
f=[a;b];
end
[t,y]=ode15s(@(t,y) DAE(t,y),[0,100],[1,1],odeset('Mass',[1 0; 0 0]))
But, cant use it when the algebraic equation depend on the result from if
function f=DAE(t,y)
if t>10 a=0; else a=10; end
b=y(2)+a;
f=[a;b];
end
[t,y]=ode15s(@(t,y) DAE(t,y),[0,100],[1,1],odeset('Mass',[1 0; 0 0]))
The solver works until the condition t>10 is reached, then I get this error: Warning: Failure at t=1.000000e+100. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.842171e-014) at time t.
The solver reduce the step size when t is near 10, and all sucesive iterations are on t=10, so I can't get the values for t>10.
I guess this happen because the "function if" is a discontinous function, so the solver get this as a singularity and his algorithm can't solve it.
So, my question is: How to use if to evaluate the independent variable, and make the algebraics equations depend on his result avoiding the solver stop working?
0 commentaires
Réponses (1)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!