how to write or condition in if statement matlab?
Show older comments
if
(j==i) , or (flag(j)==1)
Accepted Answer
More Answers (1)
Shwetank Shrey
on 21 Jun 2019
Check out the documentation:
if (j == i) || (flag(j) == 1)
% do something
end
6 Comments
Sultan Mehmood
on 21 Jun 2019
madhan ravi
on 21 Jun 2019
You need to explain what is your desired result and what you’re trying to do.
Shwetank Shrey
on 21 Jun 2019
You would have gotten this when i and/or j are arrays.
if all(j == i) || (flag(j) == 1)
% do something
end
If this still does not work, flag(j) might be returning an array too and you can add an all statement for that too.
Documentation for all : https://www.mathworks.com/help/matlab/ref/all.html
Sultan Mehmood
on 21 Jun 2019
madhan ravi
on 21 Jun 2019
What is i here , loop iterator?
Sultan Mehmood
on 21 Jun 2019
Categories
Find more on Debugging and Analysis 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!