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 个评论

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

请先登录,再进行评论。

回答(1 个)

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

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

产品

版本

R2020a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by