- when G == 11, you want th = 8 ?
- when G <= 5 , stop the loop?
- but if you stop the loop what does increasing 'th' do?
Incrementing value in an executing loop
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a matrix A =
12 13 6 7
5 4 5 1
2 2 11 13
7 1 3 6
and the following code:
%%%%(th=threshold)
th=4
for i=1:4
for j=1:4
if A(i,j) < th
A(i,j) = 0;
G=nnz(A);
end
end
end
I have calculated nnz where I get G=11,for threshold 4.
Now I want to automatically increment the th value such that if G is less than 5 the loop should termainate, and find the value of th when the loop terminated.
댓글 수: 1
Albert Yam
2012년 7월 26일
Please reword your question. I don't understand what you are asking.
From what I gather,
채택된 답변
venkat vasu
2012년 7월 27일
편집: Andrei Bobrov
2012년 7월 27일
th=4
for i=1:4
for j=1:4
if A(i,j) < th
A(i,j) = 0;
G=nnz(A);
if G<5
th=th+1;
break;
end
end
end
end
this may help you...
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
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!