how can make for-loop in an if-end command for 'and(&) ' all arrays?

3 views (last 30 days)
how can make for-loop and if-end command for all array of a matrix to be less than 2 value?(how can make for-loop in an if-end command for 'and(&)'?) foe example:
%matrix=defined matrix
how making loop for this:
if matrix(1,1)<1 && matrix(2,1)<1&& matrix(3,1)<1&& matrix(4,1)<1&& ... matrix(end,1)<1
a=2
end

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 18 Sep 2011
if all(yourmatrix(:,1)<1)
a=2;
end

More Answers (1)

TAB
TAB on 18 Sep 2011
Better option than using for loop
if(~isempty(find(matrix(:,1)<1)))
a=2;
end

Categories

Find more on Loops and Conditional Statements 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!