Matlab基本函数-length函数

1、length函数:计算向量或矩阵的长度

2、用法说明

y = length(x) 函数计算指定向量或矩阵的长度y。如果参数变量x是向量,则返回其长度;如果参数变量是非空矩阵,则length(x)与max(size(x))等价

3、举例说明

>> x = 'youhaidong'

x =

youhaidong

>> y = length(x)

y =

    10

>> x = rand(6,6)

x =

    0.8147    0.2785    0.9572    0.7922    0.6787    0.7060
    0.9058    0.5469    0.4854    0.9595    0.7577    0.0318
    0.1270    0.9575    0.8003    0.6557    0.7431    0.2769
    0.9134    0.9649    0.1419    0.0357    0.3922    0.0462
    0.6324    0.1576    0.4218    0.8491    0.6555    0.0971
    0.0975    0.9706    0.9157    0.9340    0.1712    0.8235

>> y = length(x)

y =

     6

4、附录

>> help length
 length   Length of vector.
    length(X) returns the length of vector X.  It is equivalent
    to MAX(SIZE(X)) for non-empty arrays and 0 for empty ones.
   
    See also numel.

    Overloaded methods:
       timer/length
       serial/length
       daqdevice/length
       daqchild/length
       distributed/length
       codistributed/length
       Composite/length
       gpuArray/length
       fints/length
       videosource/length
       videoinput/length
       visa/length
       udp/length
       tcpip/length
       icgroup/length
       icdevice/length
       i2c/length
       gpib/length
       Bluetooth/length
       xregpointer/length
       mbcstore/length
       guidarray/length
       cgrules/length
       designdev/length
       des_constraints/length
       coninputfactor/length
       xregcontainer/length
       xregmulti/length
       xregcovariance/length
       xregmonitorplotproperties/length
       xregdataset/length
       cgtradeoffkeytable/length
       dataset/length
       categorical/length
       tscollection/length

    Reference page in Help browser
       doc length


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值