For a 1-by-N array, they are essentially the same. For a multidimensional array M
, they can give different results:
numel(M)
is equivalent to prod(size(M))
.
length(M)
is equivalent to max(size(M))
. If M
is empty (i.e. any dimension is 0), then length(M)
is 0.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…