Find the evaluated condition in decision

조회 수: 2 (최근 30일)
Ajay krishna Vasanthakumar
Ajay krishna Vasanthakumar 2020년 5월 25일
댓글: Ajay krishna Vasanthakumar 2020년 5월 25일
Can someone help me with a program to find the condition of a decision which is executed. For example
((u == 1)&&(u1==2))||(u ==2)&&u1==2)
In this decision the if the 1st condition is satisfied the second condition is not evaluated (short circuited)
  댓글 수: 2
Rik
Rik 2020년 5월 25일
What should be the output?
Ajay krishna Vasanthakumar
Ajay krishna Vasanthakumar 2020년 5월 25일
Hello Rik Thanks for your response the output should be the condition executed.
In the above example the output should be u==1 ,u1==2 if u is 1and u1 is 2

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

답변 (1개)

Image Analyst
Image Analyst 2020년 5월 25일
Do you mean like this?
if (u == 1) && (u1==2)
% First condition code.
elseif (u == 2) && u1 == 2 % Only evaluated if the first test fails.
end
  댓글 수: 3
Ajay krishna Vasanthakumar
Ajay krishna Vasanthakumar 2020년 5월 25일
The 1st thing i should do is convert the given decision into the above code as you mentioned.
i want to handle all possible decisions
Ajay krishna Vasanthakumar
Ajay krishna Vasanthakumar 2020년 5월 25일
Small correction in the code
if (u == 1)
% u == 1 evaluated to true
if (u1 == 2)
% u1 == 2 evaluate to true
end
elseif (u == 2)
% u == 2 evaluated
if (u1 == 2)
% u1 == 2 evaluated to true
end
end

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

카테고리

Help CenterFile Exchange에서 Simscape Electrical에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by