Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
IB Ugur
IB Ugur am 31 Aug. 2017
Bearbeitet: Matt J am 31 Aug. 2017
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

Akzeptierte Antwort

Matt J
Matt J am 31 Aug. 2017
Bearbeitet: Matt J am 31 Aug. 2017
if max(W(:))-min(W(:))<=tolerance
break;
end

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by