For Loop Increment Value
조회 수: 50 (최근 30일)
이전 댓글 표시
HARSHVARDHAN SARAVANAKUMAR
2017년 2월 11일
댓글: HARSHVARDHAN SARAVANAKUMAR
2017년 2월 11일
I am beginner in MATLAB. I want to write a for loop where the increment value should increase by 2.
For eg:
for i = 1:9
something
end
The value of i should be 1, 3, 5, 7, 9. Kindly help.
댓글 수: 0
채택된 답변
Geoff Hayes
2017년 2월 11일
Just do
for k=1:2:9
% do something
end
where we have defined the step size to be two.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!