How to do: "for each value of the vector A"
92 次查看(过去 30 天)
显示 更早的评论
Hi all,
i'd like to know how is possible to get the iteration for each element of a vector. I show an example.
A=[14 5 7 3 8];
for i=each element of A
etc
end
Thanks to all will answer me.
0 个评论
回答(1 个)
madhan ravi
2019-9-14
for ii = 1:numel(A) % this is for illustration purposes
A(ii)
end
4 个评论
Stephen23
2019-9-15
Note that in most real-world code, looping over indices (as per madhan ravi's original answer), is much more useful.
Robin Amar
2021-12-23
This operation is straight forward in Python as well.
另请参阅
类别
在 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!