필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Using 'if' to evaluate independent variable on DAE

조회 수: 2 (최근 30일)
Jose
Jose 2012년 3월 31일
마감: MATLAB Answer Bot 2021년 8월 20일
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?

답변 (1개)

Jan
Jan 2012년 3월 31일
You can and should use an event, which stops the integration and restart it afterwards. Unfortunately this has to be done manually, because the event functions in Matlab's integrators cannot restart the integration with new parameters.
  댓글 수: 1
Jose
Jose 2012년 3월 31일
Thanks Jan, I'll try that.
I hope to write tomorrow about this solution.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by