Increment change For loop

22 visualizaciones (últimos 30 días)
Amir Ehsani
Amir Ehsani el 24 de Sept. de 2020
Respondida: KSSV el 24 de Sept. de 2020
Hello,
I want to gradually increase a FOR loop increment during a program.
For example:
for i=1:2:200
after 10 steps I want the step size increases automatically to 4
Thanks in advance

Respuesta aceptada

David Hill
David Hill el 24 de Sept. de 2020
for i=[1:2:19,23:4:200]
end

Más respuestas (1)

KSSV
KSSV el 24 de Sept. de 2020
val = [1:2:19,23:4:200] ;
N = length(val) ;
iwant = zeros(1,N) ;
for i = 1:N
iwant(i) = val(i) % In case you want to store some result out of it
end

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by