Basic functions matlab min

The evolution together a basic computing functions -matlab min

Find useful, welcome to discuss mutual learning together - Follow Me

  • Find the smallest element in the array

    grammar

  • M = min (A) returns the smallest element of A
    • If A is a vector, then the min (A) returns the smallest element of A
    • If A is a matrix, then the min (A) is a row vector containing the minimum value of each column
    • If A is a multidimensional array, min (A) is not equal to the first size along a 1-dimensional array operation, vector elements considered. The size of this dimension to 1, while all other dimensions remain the same size. If A is the first dimension of the array 0 is empty, then the min (A) returns the size of a space A in the same array.
  • M = min (A, [], dim) returns the smallest dimension of the elements in the dim, for example, if A is a matrix, then the min (A, [], 2) is a column vector comprising a minimum value of each line. Because the column is first dimension, the second dimension is the line, so in accordance with the line to the minimum value, the resultant is a column vector
  • [M, I] = min (___) A minimum is found the index of the input parameters and using any of the foregoing syntax return them in the output of the vector I. If the minimum occurs repeatedly, then min returns the first index corresponding to occur once
  • C = min (A, B) returns an array, from which the smallest element A or B.
  • NaN value is included or omitted when ___ = min (___, nanflag) syntax specify whether any previously calculated. For the case of a single array to be specified is not specified in the case of dim nanflag, use min (A, [], nanflag). For example, min (A, [], 'includesenan') contains all NaN values ​​over time, min (A, [], 'omitnan') ignores them.

    Examples

    Orientation minimum amount

A = [23 42 37 15 52];
M = min(A)
M =

    15

The amount of orientation smallest complex

A = [-2+2i 4+i -1-3i];
min(A)
ans =

  -2.0000 + 2.0000i

Minimum two-dimensional matrix of each column

A = [2 8 4; 7 3 9]
A =

     2     8     4
     7     3     9

M = min(A)
M =

     2     3     4

Minimum two-dimensional matrix in each row

A = [1.7 1.2 1.5; 1.3 1.6 1.99]
A =

    1.7000    1.2000    1.5000
    1.3000    1.6000    1.9900

M = min(A,[],2)
M =

    1.2000
    1.3000

Back to index the minimum value

A = [1 9 -2; 8 4 -5]
A =

     1     9    -2
     8     4    -5

[M,I] = min(A)
M =

     1     4    -5


I =

     1     2     2

Takes a smaller value corresponding to the A or B

A = [1 7 3; 6 2 9]
A =

     1     7     3
     6     2     9

B = 5;
C = min(A,B)
C =

     1     5     3
     5     2     5

Find the minimum value of the matrix

  • Minimum is found in the matrix that is the transformation matrix into a one dimensional vector, and then pick the minimum value
A = [8 2 4; 7 3 9]
A =

     8     2     4
     7     3     9

A(:)
ans =

     8
     7
     2
     3
     4
     9

[M,I] = min(A(:))
M =

     2


I =

     3
  • I is the smallest element containing A (:) index
  • Now, using the function to extract the minimum ind2sub element corresponding to the row and column indices A
[I_row, I_col] = ind2sub(size(A),I)
I_row =

     1


I_col =

     2
  • If you just need to find the minimum value of the matrix without having to be concerned about its location just needs to perform two functions min
M = min(min(A))
M =

     2

There are cases of NaN

Create a vector and calculate its minimum value does not include NaN

A = [1.77 -0.005 3.98 -2.95 NaN 0.34 NaN 0.19];
M = min(A,[],'omitnan')
M =

   -2.9500

min (A) also produce this result, because 'omitnan' default option is
to use "includes enan" flag returns NaN

M = min(A,[],'includenan')
M =

   NaN

Input parameters

Output parameters

Guess you like

Origin www.cnblogs.com/cloud-ken/p/11260481.html