1. 程式人生 > >Matlab基本函式-length函式

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


 

 

再分享一下我老師大神的人工智慧教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智慧的隊伍中來!https://www.cnblogs.com/captainbed