for loop in matlab

2 Ansichten (letzte 30 Tage)
hang dong
hang dong am 10 Jun. 2019
Kommentiert: Utkarsh Belwal am 10 Jun. 2019
How can the for loop start to start from the value 0?

Antworten (1)

Utkarsh Belwal
Utkarsh Belwal am 10 Jun. 2019
% Here is a for loop which starts from 0 and ends at 100.
for i = 0 : 100
% Your Code
end
  3 Kommentare
Walter Roberson
Walter Roberson am 10 Jun. 2019
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 am 10 Jun. 2019
MATLAB uses 1 based indexing not zero based so you can not access zero index in MATLAB.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by