bypass an "if" within another using a flag
Show older comments
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!
Accepted Answer
More Answers (1)
Image Analyst
on 8 Apr 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 Comment
Mehrdad Bahadori
on 8 Apr 2023
Edited: Walter Roberson
on 8 Apr 2023
Categories
Find more on Schedule Model Components in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!