Why does length sometimes read the number of columns instead of the number of rows?
27 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yasmin Samy
el 10 de Ag. de 2017
Comentada: Chad Greene
el 10 de Ag. de 2017
Hello, I`m looping over the length of a table (converted to array to be 'double'). However, sometimes the length reads the rows and when run again sometimes it reads columns! Why is this happening? Thanks
0 comentarios
Respuesta aceptada
Chad Greene
el 10 de Ag. de 2017
Editada: Chad Greene
el 10 de Ag. de 2017
length just tells you the longest dimension. If you're talking about a table (the piece of furniture), its length is always its longest dimension. To get just the number of rows or columns, do
rows = size(X,1);
or
cols = size(X,2);
1 comentario
Más respuestas (2)
Jan
el 10 de Ag. de 2017
Whenever you have a question concerning a command, start at the documentation:
doc length
There you find these 2 initial lines:
length
Length of largest array dimension
Sounds clear :-)
0 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion 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!