A basic question about the counter

Hello, here I have some part of my code. The thing is I want to count the code after 'else'. I can put counter, yes but It counts the total usage of that line. I want to see how many times it is being used in each row of the matris 'vertices'. I mean seperately for each row.
for M=1:m %color
for d=1:D
if abs(left_side(M,1)-vertices(d,1))<0.3 && abs(left_side(M,2)-vertices(d,2))<0.2
if vertices(d,4)==0;
vertices(d,4)=left_side(M,4);
else vertices(d,4)=(vertices(d,4)+left_side(M,4));
end
end
end
end

回答 (1 件)

madhan ravi
madhan ravi 2020 年 6 月 11 日

0 投票

counts = 0; % before loop
counts = counts + 1; % inside else part

この質問は閉じられています。

タグ

質問済み:

2020 年 6 月 11 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by