function Bsxfun, two-value operation calculated on a per-array basis between two elements

Source: Internet
Author: User
Tags square root

Transfer from http://www.cnblogs.com/rong86/p/3559616.html


function function: Two elements of an array of two-value operations calculated on a single basis

How to use: C=bsxfun (fun,a,b)

Two arrays A-in-B elements are computed two-value operations, fun is a function handle or m file, or it can be a built-in function as follows:

@plus Plus
@minus minus
@times arrays by "Simulink and Signal Processing"
@rdivide left except
@ldivide right except
@power Array Power multiplication
@max two-valued maximum value
@min minimum value of two values
@rem remainder
@mod to find a mold
@atan2 Four quadrant Arc tangent
Square root of @hypot squared sum
@eq equals
@ne Not equal to
@lt less than www.iLoveMatlab.cn
@le less than or equal to
@gt Greater than
@ge greater than or equal to
@and Logic and
@or Logical OR
@xor Logical XOR or

Application Examples:

In this example, the Bsxfun function is used to calculate the average of each column in matrix A minus its corresponding column.

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

function Bsxfun, two-value operation calculated on a per-array basis between two elements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.