Main Content

mean

Return average or mean values in DataMatrix object

Description

M = mean(DMObj) returns the mean values of the elements in the columns of a DataMatrix object, treating NaNs as missing values. M is a row vector containing the mean values for elements in each column in DMObj.

example

M = mean(DMObj,Dim) returns the mean values of the elements in the columns or rows of a DataMatrix object, as specified by Dim.

example

M = mean(DMObj,Dim,IgnoreNaN) specifies whether to ignore NaNs in DMObj when computing the mean.

Examples

collapse all

Load the file containing yeast data. This 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 variables to contain a subset of the data, specifically the first five rows and first four columns of the yeastvalues matrix, the genes cell array, and the times vector.

yeastvalues = yeastvalues(1:5,1:4);
genes = genes(1:5,:);
times = times(1:4);

Import the microarray namespace.

import bioma.data.*

Create a DataMatrix object from the gene expression data.

DMobj = DataMatrix(yeastvalues,genes,times)
DMobj = 

                  0       9.5     11.5      13.5  
    SS DNA     -0.131    1.699    -0.026     0.365
    YAL003W     0.305    0.146    -0.129    -0.444
    YAL012W     0.157    0.175     0.467    -0.379
    YAL026C     0.246    0.796     0.384     0.981
    YAL034C    -0.235    0.487    -0.184    -0.669

Compute the mean of each column in the DataMatrix object.

M_col = mean(DMobj)
M_col = 1×4

    0.0684    0.6606    0.1024   -0.0292

Compute the mean of each row in the DataMatrix object.

M_row = mean(DMobj, 2)
M_row = 5×1

    0.4768
   -0.0305
    0.1050
    0.6018
   -0.1502

Input Arguments

collapse all

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

Dimension of DMObj, specified as a numeric scalar. It specifies the dimension of DMObj to calculate the mean.

  • 1 — Returns mean values for elements in each column.

  • 2 — Returns mean values for elements in each row.

Flag to ignore NaNs in DMObj, specified as true or false. By default, the value is true, which means that the function ignores NaNs in the calculation.

Output Arguments

collapse all

Mean values of the elements of the DataMatrix object, returned as a numeric vector. The numeric vector is either of the following:

  • Row vector containing the mean values from elements in each column in DMObj (when Dim = 1)

  • Column vector containing the mean values from elements in each row in DMObj (when Dim = 2)

Data Types: double

Version History

Introduced in R2008b