Basic loop syntax in MATLAB: for k=1:n

20 visualizaciones (últimos 30 días)
mohib manzoor
mohib manzoor el 28 de En. de 2011
Comentada: Walter Roberson el 29 de Mzo. de 2021
What does it mean
for k=1:n
  2 comentarios
mohsen mohsen
mohsen mohsen el 29 de Mzo. de 2021
for i= 1:3
Walter Roberson
Walter Roberson el 29 de Mzo. de 2021
It is as described in the responses rom Sean and I, with n being 3.

Iniciar sesión para comentar.

Respuestas (2)

Sean de Wolski
Sean de Wolski el 28 de En. de 2011
it means that everything between that line
k = 1:n
and
end
will be evaluated with k = every integer between 1 and n.
doc for
for more information

Walter Roberson
Walter Roberson el 28 de En. de 2011
(Adjusting Sean's answer):
it means that everything between that line
k = 1:n
and
end
will be evaluated with k = every integer starting at 1 and not exceeding n; no iterations will be done at all if n < 1
doc for
for more information
  4 comentarios
Matt Fig
Matt Fig el 28 de En. de 2011
Jan, how do you remember these things! There are obviously no angry armadillos bouncing around in your head.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by