Check for 1 in a array
조회 수: 39 (최근 30일)
이전 댓글 표시
채택된 답변
Cedric
2014년 5월 6일
편집: Cedric
2014년 5월 6일
Here is an example:
A = randi( 10, 3 ,20 ) % Dummy example.
if any( A(2,:) == 1 )
fprintf( 'Found at least one 1 on row 2!\n' ) ;
end
Running it gives:
>> A
A =
Columns 1 through 16
1 7 5 1 6 1 3 10 7 4 4 10 6 9 4 4
3 1 2 3 6 9 1 7 5 9 4 9 2 7 6 7
2 7 4 4 8 4 9 6 10 2 10 2 9 3 8 5
Columns 17 through 20
2 6 1 6
7 8 5 10
6 2 9 7
Found at least one 1 on row 2!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!