Borrar filtros
Borrar filtros

what is the meaning of these two lines?

1 visualización (últimos 30 días)
Saf el
Saf el el 30 de Nov. de 2017
Comentada: Saf el el 30 de Nov. de 2017
siz = size(P);
for i = 1:siz(2)
with P is a 2*k matrix, P =[p1 .....pk] I want to understand what siz(2) means in the for loop. Thanks!!

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 30 de Nov. de 2017
Saf - the size function returns the dimensions of the input parameter. In your case, if P is a 2x12 matrix so size(P) is
siz = size(P);
siz =
[ 2 12 ]
The for loop then iterates from 1 to siz(2) which (in this case) will be 12. So the loop will iterate over the number of columns in P.
  3 comentarios
Saf el
Saf el el 30 de Nov. de 2017
I understand it now. Thank you Geoff!
Saf el
Saf el el 30 de Nov. de 2017
Fangjun- yes, it works. Thank you for your help!

Iniciar sesión para comentar.

Más respuestas (0)

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