Use for loop in array

1 次查看(过去 30 天)
hang dong
hang dong 2019-6-10
评论: KSSV 2019-6-10
How to use the for loop in array with a start value of 0?

回答(1 个)

KSSV
KSSV 2019-6-10
a = rand(10,1) ;
for i = 1:length(a)
a(i)
end
  6 个评论
hang dong
hang dong 2019-6-10
I want to create an array of n elements, then programmatically to swap values ​​in that S array, in the array containing element 0
KSSV
KSSV 2019-6-10
You can get the index of 0 using
idx = find(a==0)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by