Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
IB Ugur
IB Ugur el 31 de Ag. de 2017
Editada: Matt J el 31 de Ag. de 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

Respuesta aceptada

Matt J
Matt J el 31 de Ag. de 2017
Editada: Matt J el 31 de Ag. de 2017
if max(W(:))-min(W(:))<=tolerance
break;
end

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by