Use for loop in array

Respuestas (1)

KSSV
KSSV el 10 de Jun. de 2019

0 votos

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

6 comentarios

hang dong
hang dong el 10 de Jun. de 2019
Can I start with 0?
KSSV
KSSV el 10 de Jun. de 2019
No..MATLAB does not accept index as zero. It should be positive integer.
hang dong
hang dong el 10 de Jun. de 2019
So is there a way for me to replace 0?
KSSV
KSSV el 10 de Jun. de 2019
What is your purpose? Explain your problem.
hang dong
hang dong el 10 de Jun. de 2019
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 el 10 de Jun. de 2019
You can get the index of 0 using
idx = find(a==0)

Iniciar sesión para comentar.

Categorías

Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Jun. de 2019

Comentada:

el 10 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by