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

2 ビュー (過去 30 日間)
mohammad
mohammad 2011 年 9 月 18 日
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

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 9 月 18 日
if all(yourmatrix(:,1)<1)
a=2;
end

その他の回答 (1 件)

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by