bypass an "if" within another using a flag
Afficher commentaires plus anciens
Hi everyone,
I have the code below:
a=5; b=4; c=3; d=2;
if a>b
if b>c % ====> this
if c>d
disp('i''m in!')
end
end % ======> this
end
Is it possible I bypass the " if b>c" using a flag?
e.g. FLAG=1, include this if, and FLAG=0, bypass this if.
Thanks!
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 8 Avr 2023
Since the b>c test occurs only inside the a>b block, and it's the only thing in the a>b block, you could simply do
if a>b && b>c
if c>d
disp('i''m in!')
end
end
1 commentaire
Mehrdad Bahadori
le 8 Avr 2023
Modifié(e) : Walter Roberson
le 8 Avr 2023
Catégories
En savoir plus sur Schedule Model Components dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!