Matlab -- floor函數的用法


1、floor函數:朝負無窮大方向取整

2、用法說明:

      y = floor(x) 函數將x中元素取整,值y為不大於本身的最大整數。對於復數,分別對實部和虛部取整

3、用法舉例

例1:

>> x = [3+4i 6-7i 9+11i 1-4i 3.4-4.5i 90.67-123i]

x =

   1.0e+02 *

  Columns 1 through 5

   0.0300 + 0.0400i   0.0600 - 0.0700i   0.0900 + 0.1100i   0.0100 - 0.0400i   0.0340 - 0.0450i

  Column 6

   0.9067 - 1.2300i

>> y = floor(x)

y =

   1.0e+02 *

  Columns 1 through 5

   0.0300 + 0.0400i   0.0600 - 0.0700i   0.0900 + 0.1100i   0.0100 - 0.0400i   0.0300 - 0.0500i

  Column 6

   0.9000 - 1.2300i

例2:

 

>> a= 2*rand(4)

a =

    1.9298    0.9708    1.8315    0.0714
    0.3152    1.6006    1.5844    1.6983
    1.9412    0.2838    1.9190    1.8680
    1.9143    0.8435    1.3115    1.3575

>> x = floor(a)

x =

     1     0     1     0
     0     1     1     1
     1     0     1     1
     1     0     1     1


>> b = floor(a + rand(4)*i)


b =

     2     1     3     0
     1     2     2     1
     3     1     3     2
     2     2     2     3

 

4、附錄

>> help floor
 floor  Round towards minus infinity.
    floor(X) rounds the elements of X to the nearest integers
    towards minus infinity.
 
    See also round, ceil, fix.

    Overloaded methods:
       codistributed/floor
       gpuArray/floor

    Reference page in Help browser
       doc floor

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM