for loop in matlab
1 次查看(过去 30 天)
显示 更早的评论
How can the for loop start to start from the value 0?
0 个评论
回答(1 个)
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
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
2019-6-10
MATLAB uses 1 based indexing not zero based so you can not access zero index in MATLAB.
另请参阅
类别
在 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!