Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
IB Ugur
IB Ugur le 31 Août 2017
Modifié(e) : Matt J le 31 Août 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

Réponse acceptée

Matt J
Matt J le 31 Août 2017
Modifié(e) : Matt J le 31 Août 2017
if max(W(:))-min(W(:))<=tolerance
break;
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by