for loop in matlab

조회 수: 2 (최근 30일)
hang dong
hang dong 2019년 6월 10일
댓글: Utkarsh Belwal 2019년 6월 10일
How can the for loop start to start from the value 0?

답변 (1개)

Utkarsh Belwal
Utkarsh Belwal 2019년 6월 10일
% Here is a for loop which starts from 0 and ends at 100.
for i = 0 : 100
% Your Code
end
  댓글 수: 3
Walter Roberson
Walter Roberson 2019년 6월 10일
You can never index at 0 in MATLAB, regardless of what your loop starts at.
for i = 0 : 100
y(i+1) = x(i).^2 + 5;
end
Utkarsh Belwal
Utkarsh Belwal 2019년 6월 10일
MATLAB uses 1 based indexing not zero based so you can not access zero index in MATLAB.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by