Is there a way to have an option in the conditional go to another part of the conditional?
Show older comments
I have one large for loop with nested if statements. In the first set of if statements the final result is supposed to be an fprintf statement if a value of a calculation is less than one. If it's not less than one I don't have an option because i want it to go to the elseif statement. Is there a way to do that?
Answers (2)
Azzi Abdelmalek
on 8 Mar 2013
0 votes
If the first condition is false, automatically it goes to the nes if.
Walter Roberson
on 9 Mar 2013
If you mean a structure such as
if condition1
if condition2
fprintf(...)
else
%HERE we want to continue at THERE
end
else
%THERE
end
then NO, there is no mechanism for that.
You can use
if condition1 & condition2
fprintf(...)
else
%THERE
end
and if you need to you can use
goThere = true;
if condition1
... do a calculation here ...
if ~conditon2
goThere = false;
end
end
if ~goThere
fprintf(...)
else
%THERE
end
Categories
Find more on Document and Integrate Toolboxes in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!