I can combine for loop outputs
3 ビュー (過去 30 日間)
古いコメントを表示


this is my code. i create a function that when input limit is given it says how many elements of matrix is greater that the limit. i want to get output = 2 but because of for loop it gives it sepereatky. How to sum them?
0 件のコメント
採用された回答
その他の回答 (1 件)
Walter Roberson
2020 年 12 月 6 日
When A is a variable rather than a function, length(A(i,j)) is always going to be 1 when i and j are both scalar (well, except for cases where i or j are out of bounds for the array size.)
Instead of disp() anything at that point, add 1 to a counter. Later return the counter or display the counter.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!