Retrieve condition in if-else loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163856/image.jpeg)
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
0 commentaires
Réponses (1)
Walter Roberson
le 9 Mai 2017
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
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!