Use for loop in array
Show older comments
How to use the for loop in array with a start value of 0?
Answers (1)
KSSV
on 10 Jun 2019
a = rand(10,1) ;
for i = 1:length(a)
a(i)
end
6 Comments
hang dong
on 10 Jun 2019
KSSV
on 10 Jun 2019
No..MATLAB does not accept index as zero. It should be positive integer.
hang dong
on 10 Jun 2019
KSSV
on 10 Jun 2019
What is your purpose? Explain your problem.
hang dong
on 10 Jun 2019
KSSV
on 10 Jun 2019
You can get the index of 0 using
idx = find(a==0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!