Reputation: 2005
I have been trying to find the number of columns of an array but apparently the ncols
, size
, and length
functions don't produce the desired output.
Any suggestion on what is the correct way to find the number of columns of an array?
Thanks in advance.
Upvotes: 7
Views: 4374
Reputation: 12664
To find the number of rows of an array, X
:
size(X, 1)
To find the number of columns
size(X, 2)
For the length of the n'th dimension:
size(X, n)
Upvotes: 10