主要内容

max

Return maximum values in DataMatrix object

Description

M = max(DMObj1) returns the maximum values in DMObj1, a DataMatrix object.

example

[M, Indices] = max(DMObj1) also returns Indices, the indices of the maximum values in DMObj1.

example

[M,Indices,Names] = max(DMObj1) also returns Names, a vector of the row or column names corresponding to the maximum value in each column or each row of DMObj1.

example

___ = max(DMObj1,[],Dim) specifies which dimension to return the maximum values for in a DataMatrix object for any of the previous output arguments.

example

MA = max(DMObj1,DMObj2) returns MA, a numeric array containing the larger of the two values from each position of DMObj1 and DMObj2.

example

Examples

collapse all

Load the MAT-file, provided with the software, that contains yeast data. This MAT-file includes three variables: yeastvalues, a 614-by-7 matrix of gene expression data, genes, a cell array of 614 GenBank® accession numbers for labeling the rows in yeastvalues, and times, a 1-by-7 vector of time values for labeling the columns in yeastvalues.

load filteredyeastdata

Create two subsets of the data.

yeastvalues2 = yeastvalues(1:5,:);
genes2 = genes(1:5,:);
dm1 = bioma.data.DataMatrix(yeastvalues2,genes2,times)
dm1 = 

                  0       9.5     11.5      13.5      15.5      18.5      20.5  
    SS DNA     -0.131    1.699    -0.026     0.365    -0.246     0.478     0.435
    YAL003W     0.305    0.146    -0.129    -0.444    -0.707    -1.499    -1.935
    YAL012W     0.157    0.175     0.467    -0.379     -0.52    -1.279    -2.125
    YAL026C     0.246    0.796     0.384     0.981      1.02     1.646     1.157
    YAL034C    -0.235    0.487    -0.184    -0.669    -1.006     2.369     2.611
yeastvalues3 = yeastvalues(6:10,:);
genes3 = genes(6:10,:);
dm2 = bioma.data.DataMatrix(yeastvalues3,genes3,times)
dm2 = 

                  0       9.5      11.5      13.5      15.5      18.5      20.5  
    YAL061W    -0.532     0.028    -0.333    -0.102     1.172     2.087     0.992
    YAR027W    -0.003     0.522     0.347     0.806     0.756     1.949     1.065
    YAR073W     0.395     0.536     0.422     0.113    -0.226    -1.681    -1.857
    YBR006W    -0.665    -0.724     0.419     0.505     0.499      1.53     1.755
    YBR018C    -0.619    -1.682    -0.043     -0.37    -0.767      0.75     0.903

Get the maximum value from each column, that is, dimension = 1.

[m1,indices1,names1] = max(dm1)
m1 = 1×7

    0.3050    1.6990    0.4670    0.9810    1.0200    2.3690    2.6110

indices1 = 1×7

     2     1     3     4     4     5     5

names1 = 1×7 cell
    {'YAL003W'}    {'SS DNA'}    {'YAL012W'}    {'YAL026C'}    {'YAL026C'}    {'YAL034C'}    {'YAL034C'}

Get the maximum value from each row, that is, dimension = 2.

[m2,indices2,names2] = max(dm1,[],2)
m2 = 5×1

    1.6990
    0.3050
    0.4670
    1.6460
    2.6110

indices2 = 5×1

     2
     1
     3
     6
     7

names2 = 5×1 cell
    {' 9.5'}
    {'   0'}
    {'11.5'}
    {'18.5'}
    {'20.5'}

Compare two DataMatrix and get the larger value for each element.

MA = max(dm1,dm2)
MA = 5×7

   -0.1310    1.6990   -0.0260    0.3650    1.1720    2.0870    0.9920
    0.3050    0.5220    0.3470    0.8060    0.7560    1.9490    1.0650
    0.3950    0.5360    0.4670    0.1130   -0.2260   -1.2790   -1.8570
    0.2460    0.7960    0.4190    0.9810    1.0200    1.6460    1.7550
   -0.2350    0.4870   -0.0430   -0.3700   -0.7670    2.3690    2.6110

Input Arguments

collapse all

DataMatrix, specified as a bioma.data.DataMatrix object.

DataMatrix, specified as a bioma.data.DataMatrix object.

Dimension of DataMatrix to return the maximum values for, specified as 1 or 2.

If Dim is 1, the function returns a row vector containing maximum value for each column. If Dim is 2, the function returns a column vector containing a maximum value for each row.

Output Arguments

collapse all

Maximum value, returned as one of the following:

  • Scalar specifying the maximum value in DMObj1 when DMObj1 contains vector of data

  • Row vector containing the maximum value for each column in DMObj1 when DMObj1 is a matrix and Dim = 1.

  • Column vector containing the maximum value for each row in DMObj1 when DMObj1 is a matrix and Dim = 2.

Data Types: double

Indices of maximum values, returned as one of the following:

  • Positive integer specifying the index of the maximum value in a DataMatrix object containing a vector of data

  • Vector containing the indices for the maximum value in each column, if Dim = 1, or in each row, if Dim = 2, in a DataMatrix object containing a matrix of data

Row or column names, returned as a cell array of character vectors.

The function returns a vector of the row names if Dim = 1) or column names if Dim = 2, corresponding to the maximum value in each column or each row of DMObj1. If there are multiple maximum values in a column or row, the row or column name for the first value is returned.

Data Types: char | string

Numeric output, returned as a numeric array containing the larger of the two values from each position of DMObj1 and DMObj2.

DMObj1 and DMObj2 can both be DataMatrix objects, or one can be a DataMatrix object and the other a numeric array. They must be the same size, unless one is a scalar. MA has the same size (number of rows and columns) as the first nonscalar input.

Data Types: double

Version History

Introduced in R2008b

See Also

| |