vector that displays [0 5 10 15]
2 次查看(过去 30 天)
显示 更早的评论
i want a for loops that displays the following vector
[0 5 10 15]
采纳的回答
Davide Masiello
2022-5-18
Just be aware of the fact that you do not need to use a loop to do this
A = 0:5:15
That said, if you really must use a loop, then you could write
A = zeros(1,4);
for idx = 1:3
A(idx+1) = idx*5;
end
A
I strongly recommend going with the first option.
0 个评论
更多回答(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!