add count in a for loop

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 Comments

What’s your question?
i want to add a count of elements greater than 20 and less than 70 for a 10x10 matrix

Sign in to comment.

Answers (1)

[row, column] = deal(1:10);
Counts = nnz(((row .* column(:)) > 70) & ((row .* column(:)) < 20))

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2020a

Tags

Asked:

on 27 Aug 2020

Answered:

on 27 Aug 2020

Community Treasure Hunt

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

Start Hunting!