for loop in matlab

8 ビュー (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by