函數bsxfun,兩個數組間元素逐個計算的二值操作

來源:互聯網
上載者:User

標籤:大於   mod   pow   max   元素   異或   計算   link   rem   

轉自http://www.cnblogs.com/rong86/p/3559616.html


函數功能:兩個數組間元素逐個計算的二值操作

使用方法:C=bsxfun(fun,A,B)

兩個數組A合B間元素逐個計算的二值操作,fun是函數控制代碼或者m檔案,也可以為如下內建函數:

@plus 加
@minus 減
@times 數組乘《Simulink與訊號處理》
@rdivide 左除
@ldivide 右除
@power 數組冪乘
@max 二值最大值
@min 二值最小值
@rem 餘數
@mod 求模
@atan2 四象限反正切
@hypot 平方和的平方根
@eq 等於
@ne 不等於
@lt 小於www.iLoveMatlab.cn
@le 小於或等於
@gt 大於
@ge 大於或等於
@and 邏輯並
@or 邏輯或
@xor 邏輯異或

應用舉例:

在此例子中,bsxfun函數用來計算矩陣A每一列減去其對應列的平均值.

A = magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
A = bsxfun(@minus, A, mean(A))book.iLoveMatlab.cn
A =

4 11 -12 -5 2
10 -8 -6 1 3
-9 -7 0 7 9
-3 -1 6 8 -10
-2 5 12 -11 -4

函數bsxfun,兩個數組間元素逐個計算的二值操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.