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

 채택된 답변

David Hill
David Hill 2020년 9월 24일

1 개 추천

for i=[1:2:19,23:4:200]
end

추가 답변 (1개)

KSSV
KSSV 2020년 9월 24일

1 개 추천

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 9월 24일

답변:

2020년 9월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by