필터 지우기
필터 지우기

How to enter an if...else...end statement for a dae problem

조회 수: 1 (최근 30일)
Urvi
Urvi 2012년 10월 1일
This is my m file:
*M file* function f=ncs1_dae(t,x)
%Input parameters
global alpha A AH AI AO AV ACS beta CPH CPI CPIN CPO CPV dB g hB hI hO hH hV Hmax k M MH min Pset qein R rhol rhov ri ro TIN TR vB lambda;
input()
%Variables
TI=x(1);
........
..........
=x(16);
%f(1) to f(6) are ODEs
f(1)=
f(2)=
f(3)=
f(4)=
f(5)=
f(6)=
%f(7) to f(18) are Algebraic Equations
f(7)=
f(8)=
f(9)=
f(10)=
f(11)=
f(12)=
f(13)=
f(14)=
f(15)=
f(16)=
f(17)=
f(18)=
f=f';
My question is:
I want to enter if....else statements for a few equations...For example, in f(7), if PV<=Pset, mout = 0 else f(7)=. How can I incorporate that. I need to do this for 5-6 equations. Thanks!
  댓글 수: 3
Urvi
Urvi 2012년 10월 3일
Please help! its urgent!

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

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 3일
if PV<=Pset
mout = 0
else
f(7)=mout-alpha*(PV-Pset)
end
in general
if condition1
% action1
elseif condition2
% action2
elseif condtion n
% action n
else
% action n+1
end
  댓글 수: 1
Urvi
Urvi 2012년 10월 3일
I have already tried this but I get an error saying "DAE index appears to be greater than 1".

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


Jan
Jan 2012년 10월 3일
The DAE (or ODE) function must be continuous. Therefore IF, MAX, ABS and time-dependent functions are a big DON'T in functions to be integrated. Use event functions instead.
Remember, that the trajectory of an DAE must be kept on a feasible path. Could this be the case, when you insert a discontinuity?

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by