Matlab:max function

Source: Internet
Author: User

In MATLAB, the Max function in the matrix to find the function of the size of the example is as follows:

C = max (A)
Returns the largest element in a different dimension of an array.
If a is a vector, Max (a) returns the largest element in a.
If A is a matrix, Max (a) takes each column of a as a vector, and returns a row of vectors containing the largest element of each column.
If a is multiple arrays, Max (a) treats the values along the first Non-singleton dimension as vectors, returning the maximum value of each Vector.

C = Max (A, B)
Returns an array of the same size as a and B, where the element is the largest element taken out of a or B.

C = max (A,[],dim)
Returns the maximum value in the range of dimensions that have dim specified in A.

[C,i] = max (...)
Find the index positions of those maximum values in a, and return them in vector i. If there are more than one of the same maximum values, the index returned will be the first one.

Detailed Examples:

The Max function in MATLAB
One: Several forms of the Max function
(1) Max (a) (2) Max (A, B) (3) Max (A,[],dim) (4) [C,i]=max (a) (5) [C,i]=max (A,[],dim)
Two: illustrate the function meaning
(1) Max (a)
If A is a matrix, for example, A=[1,2,3;4,5,6],max (a) means finding the maximum value of each column in the matrix, in this case: Max (a) =[4,5,6]
(2) Max (A, B)
If both A and B are matrices larger than 1-dimensional, then the dimensions of the columns of A and B are required to be equal, and the result of the function is to compare the size of each element in a and B, for example:
a=[1,2,3;4,5,6] b=[4,5,6;7,8,3] Max (A, b) =[4,5,6;7,8,6]

In addition, if at least one of A and B is a constant, it is also possible.

For example: a=[1,2,3;4,5,6] b=3 c=5
Max (A, b) =[3,3,3;4,5,6]

Max (B,C) =5

I believe everyone has read the example and understood the meaning of the function.
(3) max (A,[],dim)
The meaning of this function is for the 2-dimensional matrix, Dim is the abbreviation for the English letter dimension, which means the dimension number. When Dim=1, the rows of a matrix compared to the effect of Max (a) are the same; when dim2, the rows of a matrix are compared. Here's an example:
a=[1,2,3;4,5,6] Max (a) =max (a,[],1) =[4,5,6] Compare the values of the first and second rows Max (a,[],2) =[3,6]

(4) [C,i]=max (a)
C represents the maximum value for each column of matrix A, and I represents the subscript for each of the maximum values: The following examples illustrate:
Or just that example: a=[1,2,3;4,5,6] [C,i]=max (a)
The result shows that c=[4,5,6] i=[2,2,2] Returns the line number corresponding to the maximum value.
(5) [C,i]=max (A,[],dim)
Similarly: if dim=1, the result is the same as [C,i]=max (a). When dim=2, the same above matrix A, let's run it:
[C,i]=max (a,[],2) The result is: c=[3,6] i=[3,3] I returns the column number of matrix A.

----------------------------------------------
Max

Maximum elements of an array

Syntax

C = max (A)
C = Max (A, B)
C = max (A,[],dim)
[C,i] = max (...)

Description

C = max (A) returns the largest elements along different dimensions of an array. If A is a vector, max (A) returns the largest element in a. If A is a matrix, Max (a) treats the columns of a as vectors, returning A row vector containing the maximum element from EA CH column. If A is a multidimensional array, max (A) treats the values along the first Non-singleton dimension as vectors, returning t He maximum value of each vector.

C = Max (A, B) returns an array the same size as a and B with the largest elements taken from A or B.

C = max (A,[],dim) returns the largest elements along the dimension of A specified by scalar dim. For example, Max (a,[],1) produces the maximum values along the first dimension (the rows) of A.

[C,i] = max (...) finds the indices of the maximum values of A, and returns them in output vector I. If There is several identical maximum values, the index of the first one found is returned.

Remarks

For complex input A, MAX returns the complex number with the largest complex modulus (magnitude), computed with Max (ABS (A) ), and ignores the phase angle, angle (A). The Max function ignores NaNs.

See Also

isNaN, mean, median, min, sort

Matlab:max function

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.