필터 지우기
필터 지우기

add count of elements on a for loop to count values greater than and less than

조회 수: 1 (최근 30일)
for Row = (1:10)
for Column = (1:10)
fprintf('%d\t',Row*Column);
end
fprintf('\n');
numberofelements = sum(Row*Column(:)<70)+ Row*Column(:)>20);
end
  댓글 수: 4
Aaron Aguilar
Aaron Aguilar 2020년 8월 27일
i want to call the matrix to get the count of element greater than 20 and less than 70 in matrix table 10x10
A was not suppose to be there
Aaron Aguilar
Aaron Aguilar 2020년 8월 27일
code generates a 10x10 table, would like to count elements in table greater than 20 and less than 70 in code above

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2020년 8월 27일
A = rand(1,10) ;
N = nnz(A<0.5 | A>0.8)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by