필터 지우기
필터 지우기

How can i stop loop if all matrix elements are similar?

조회 수: 1 (최근 30일)
IB Ugur
IB Ugur 2017년 8월 31일
편집: Matt J 2017년 8월 31일
The matrix is modified in each iteration. When all elements of matrix are similar i want to stop the iteration. For example i tried by using codes shown below but it doesnt work. May you help me for solving this problem?
iteration=0;
np=10;
W=zeros(np,1);
while iteration<1000
Wupdate %The sub-script that modify the matrix
if np*W(1)==sum(W)
iteration=10000
end
end

채택된 답변

Matt J
Matt J 2017년 8월 31일
편집: Matt J 2017년 8월 31일
if max(W(:))-min(W(:))<=tolerance
break;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by