Borrar filtros
Borrar filtros

Retrieve condition in if-else loop

1 visualización (últimos 30 días)
siti khadijah
siti khadijah el 8 de Mayo de 2017
Respondida: Walter Roberson el 9 de Mayo de 2017
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

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Mayo de 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

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by