matlab 定义:
Description
L = length(X)
returns the length of the largest array dimension in X. For vectors, the length is simply the number of elements. For arrays with more dimensions, the length is max(size(X)). The length of an empty array is zero.
在X中,返回最大的维度的长度。对于向量,返回值仅为元素的个数。
对于矩阵(多维向量,向量是一维的)。这个长度就是max(size(x)),空数组的length值就是0。
可以这样理解:
对于向量,如x=[1,2…n],length(x),返回值就是n。
对于矩阵,x=[1,2;2,3;4,5] length(x),返回值是3,因为这是一个2行三列矩阵,length取最大值,2《3,所以返回值是3