iterating values of a vector under conditions
Mostrar comentarios más antiguos
I have a for loop to make the elements of vector v. I want to do iteration i+1 only for the elements with zero value in iteration i. (meaning that if I get v=[0,1,0,1] with i=1, I want to do iteration i=2 only for the 1st and 3rd elements.I need to break the loop whenever all the elements of v are filled with non zero values.
v=[0;0;0;0] for i=1:maxit
v=[process1(i)...;process2(i)...;process3(i)...;process4(i)...]
end
Respuesta aceptada
Más respuestas (2)
I am not quite sure what you want, but perhaps you should look at the CONTINUE keyword. If this isn't what you need, you should come up with an example input and an expected output...
Azzi Abdelmalek
el 12 de Sept. de 2012
Editada: Azzi Abdelmalek
el 12 de Sept. de 2012
v=[0,1,0,1]
idx=find(v==0)
p=process(idx)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!