Retrieve condition in if-else loop
이전 댓글 표시
Hai guys,
I would like to ask for your opinion on my code. I'm having difficulties on getting a right system code. Here is the idea of my code:
%%Red line 1: decrease
t1 = a + b; % Tmax
t2 = t1 + c; % tcem
t3 = d; %tor_task
%%indicator to increase the red line
if t2 <= t3
t4 = e1 + f1;
if t2 <= 10 % red line 2 : increase
t2 = t1 - 10*t2
%%indicator to decrease the red line 3
if t2 == t1
t2 = t1 + c
end
end
else
t4 = e2 + f2;
t2 = t1 + c;
end

If you guys noticed, there are two ways to calculate the t2:
(1) t2 = t1 + c
(2) t2 = t1 - 10*t2
My question is, how I can ask the code for ' t2 == t1 ' to go to the 'else' at the last part of the code? Is there any ways to do that?
Thanks for your help and idea.
Regards,
Me
답변 (1개)
Walter Roberson
2017년 5월 9일
if this
hit_special_case = false;
if that
...
else
hit_special_case = false;
end
else
hit_special_case = true;
end
if hit_special_case
do something appropriate
end
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!