Retrieve condition in if-else loop

1 次查看(过去 30 天)
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
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

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by