Engee documentation

max

The maximum elements of the array.

Library

EngeeDSP

Syntax

Function call

  • M = max(A) — returns the maximum elements of the array.

    • If A — vector, then max(A) returns the maximum value A.

    • If A — the matrix, then max(A) — vector-a row containing the maximum value of each column A.

    • If A — a multidimensional array, then max(A) it operates on the first dimension A, the size of which is not equal to 1 considering the elements as vectors. Size M in this dimension , it becomes equal to 1, while the dimensions of all other dimensions remain the same as in A. If A — an empty array, the first dimension of which has zero length, then M — an empty array of the same size as A.

  • M = max(A, [], "all") — returns the maximum for all elements A.

  • M = max(A, [], dim) — returns the maximum element in terms of dimension dim. For example, if A — the matrix, then max(A,[],2) returns a column vector containing the maximum value of each row.

  • M = max(A, [], vecdim) — returns the maximum dimension specified in the vector vecdim. For example, if A — the matrix, then max(A,[],[1 2]) returns the maximum for all elements of the matrix A since each element of the matrix is contained in an array layer defined by the dimensions 1 and 2.

  • M = max(A, [], _, missingflag) — also specifies how to handle missing values for any of the previous syntax options. For example, max(A,[],"includenan") includes all missing values when calculating the maximum. By default max excludes missing values.

  • M, I = max(_) — also returns the index in the working dimension corresponding to the first occurrence of the maximum value. A.

  • M, I = max(A, [], _, "linear") — also returns a linear index in A, corresponding to the maximum value in A.

  • C = max(A, B) — returns an array with the smallest elements taken from A or B.

  • C = max(A, B, missingflag) — also specifies how to handle missing values.

  • _ = max(_, "ComparisonMethod",method) — also specifies a way to compare elements for any of the previous syntax options. For example, for a vector A = [-1 2 -9] syntax max(A,[],"ComparisonMethod","abs") compares elements A by their absolute values and returns the maximum value -9.

Arguments

Input arguments

# A — input data

+ scalar | vector | the matrix | multidimensional array

Details

Input data specified as a scalar, vector, matrix, or multidimensional array.

  • If A is a complex number, then max(A) returns the complex number with the smallest absolute value. If the values are equal, then max(A) returns the value with the smallest absolute value and the smallest phase angle.

  • If A — a scalar, then max(A) returns A.

  • If A — an empty array of size 0 on 0 Then max(A) it will also be an empty array.

Типы данных

Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Support for complex numbers

Yes

# dim — the measurement for which the operation is performed

+ scalar

Details

The dimension on which the operation is performed is set as a positive integer scalar. If no dimension is specified, then the first dimension of the array is used by default, the size of which is not equal to 1.

Dimension dim specifies a dimension whose length is reduced to 1. Size size(M, dim) equal to 1 while the dimensions of all other dimensions remain the same, unless size(A, dim) not equal to 0. If size(A, dim) equal to 0, then the function max(A, dim) returns an empty array of the same size as A.

Consider the input matrix A size on :

  • max(A,[],1) calculates the maximum of elements in each column of the matrix A and returns a vector string of the size 1 on .

max 1

  • max(A,[],2) calculates the maximum of elements in each row of the matrix A and returns a column vector of size 1 on .

max 2

# vecdim — measurement vector

+ vector

Details

A vector of dimensions defined as a vector of positive integers. Each element represents a dimension of the input array. The length of the output data in the specified operating measurements is 1, while the other dimensions remain unchanged.

Consider the input array A size 2×3×3. Then max(A,0,[1 2]) returns an array of size 1×1×3, the elements of which are the maximum values calculated for each layer A.

std 3 en

# missingflag — condition for missing a value

+ "omitnan" (by default) | "includenan"

Details

The condition for missing a value, set as:

  • "includenan" takes into account missing values in the input data. If any element is missing in the working dimension, then the corresponding element in the M also missing.

  • "omitnan" ignores the missing values in the input data and calculates the maximum from a smaller number of points. If all the elements in the working dimension are missing, then the corresponding elements in M also missing.

# B — additional input data

+ scalar | vector | the matrix | multidimensional array

Details

Additional input data, specified as a scalar, vector, matrix, or multidimensional array. Input data A and B they must be the same size or have compatible sizes (for example, A — matrix size on , and B — a scalar or vector string of the size 1 on ).

  • If A and B — arrays, then they must have the same data type, except when one of them is a type Float64. In this case, the data type of the other array may be Float32 or any integer type.

Типы данных

Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Support for complex numbers

Yes

# method — comparison method

+ "auto" (by default) | "real" | "abs"

Details

The comparison method for the input data, specified by one of the following values:

  • "auto" — for A compare elements by value real(A) if A a real number, and by value abs(A) if A comprehensive.

  • "real" — for A compare elements by value real(A) if A real or complex. If the elements A if they have equal real parts, then the function is used to resolve the matches imag(A).

  • "abs" — for A compare elements by value abs(A) if A real or complex. If the elements A if they have equal absolute values, then the function is used to resolve the matches angle(A) in the interval .

Output arguments

# M — maximum values

+ scalar | vector | the matrix | multidimensional array

Details

The maximum values returned as a scalar, vector, matrix, or multidimensional array. Size size(M,dim) equal to 1, while the dimensions of all other dimensions match the size of the corresponding dimension in A if size(A,dim) not equal to 0. If size(A,dim) equal to 0 Then M — an empty array of the same size as A.

# I — index

+ scalar | vector | the matrix | multidimensional array

Details

The index returned as a scalar, vector, matrix, or multidimensional array. Argument I it has the same size as the first output parameter.

If the call does not specify "linear" Then I — this is the index of the working measurement. If the call specifies "linear" Then I contains linear indexes A, corresponding to the maximum values.

If the smallest element occurs more than once, then I contains the index of the first occurrence of the value.

# C — maximum elements from A or B
scalar | vector | the matrix | multidimensional array

Details

Maximum elements from A or B returned as a scalar, vector, matrix, or multidimensional array. Size C it is determined by the implicit expansion of dimensions A and B.

Data type C depends on the data types A or B:

  • If A and B have the same data type, then C corresponds to the data type A and B.

  • If A or B has a type Float32 Then C It also has a type Float32.

  • If one of the A or B has an integer type, and the other is a type Float64 Then C it has an integer type.

Examples

The maximum element of a real vector

Details

Let’s create a vector and find the maximum element and its index.

import EngeeDSP.Functions: max

A = [23, 42, 37, 15, 52]
M = max(A)
(M = 52, I = 5)

The maximum element of a complex vector

Details

Let’s create a complex vector and find the maximum element and its index.

import EngeeDSP.Functions: max

A = [-2+2im, 4+1im, -1-3im]
M = max(A)
(M = 4 + 1im, I = 2)