Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Aaron Aguilar
Aaron Aguilar am 27 Aug. 2020
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 am 27 Aug. 2020
code generates a 10x10 table, would like to count elements in table greater than 20 and less than 70 in code above

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 27 Aug. 2020
A = rand(1,10) ;
N = nnz(A<0.5 | A>0.8)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by