MATLAB Answers

0

Use for loop in array

Asked by hang dong on 10 Jun 2019
Latest activity Commented on by KSSV
on 10 Jun 2019
How to use the for loop in array with a start value of 0?

  0 Comments

Sign in to comment.

1 Answer

Answer by KSSV
on 10 Jun 2019

a = rand(10,1) ;
for i = 1:length(a)
a(i)
end

  6 Comments

KSSV
on 10 Jun 2019
What is your purpose? Explain your problem.
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
on 10 Jun 2019
You can get the index of 0 using
idx = find(a==0)

Sign in to comment.