Azzera filtri
Azzera filtri

add count in a for loop

1 visualizzazione (ultimi 30 giorni)
Aaron Aguilar
Aaron Aguilar il 27 Ago 2020
Risposto: madhan ravi il 27 Ago 2020
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
  2 Commenti
madhan ravi
madhan ravi il 27 Ago 2020
What’s your question?
Aaron Aguilar
Aaron Aguilar il 27 Ago 2020
i want to add a count of elements greater than 20 and less than 70 for a 10x10 matrix

Accedi per commentare.

Risposte (1)

madhan ravi
madhan ravi il 27 Ago 2020
[row, column] = deal(1:10);
Counts = nnz(((row .* column(:)) > 70) & ((row .* column(:)) < 20))

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by