Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Matt J
Matt J il 31 Ago 2017
Modificato: Matt J il 31 Ago 2017
if max(W(:))-min(W(:))<=tolerance
break;
end

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by