I know that length(x) returns max(size(x)) and numel(x) returns the total number of elements of x, but which is better for a 1 by n ar
length(x)
max(size(x))
numel(x)
For a 1-by-N array, they are essentially the same. For a multidimensional array M, they can give different results:
M
prod(size(M))
max(size(M))
length(M)