Filter löschen
Filter löschen

Find the evaluated condition in decision

2 Ansichten (letzte 30 Tage)
Ajay krishna Vasanthakumar
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 Kommentare
Rik
Rik am 25 Mai 2020
What should be the output?
Ajay krishna Vasanthakumar
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 25 Mai 2020
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 Kommentare
Ajay krishna Vasanthakumar
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
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simscape Electrical finden Sie in Help Center und File Exchange

Produkte


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by