Documentation Center

  • Trial Software
  • Product Updates



Retrieve or set sample names in MetaData object


SamFeatNames = sampleNames(MDObj)
SamFeatNames = sampleNames(MDObj, Subset)
NewMDObj = sampleNames(MDObj, Subset, NewSamFeatNames)


SamFeatNames = sampleNames(MDObj) returns a cell array of strings specifying all sample names in a MetaData object.

SamFeatNames = sampleNames(MDObj, Subset) returns a cell array of strings specifying a subset the sample names in a MetaData object.

NewMDObj = sampleNames(MDObj, Subset, NewSamFeatNames) replaces the sample names specified by Subset in MDObj, a MetaData object, with NewSamFeatNames, and returns NewMDObj, a new MetaData object.

Input Arguments


Object of the class.


One of the following to specify a subset of the sample names in a MetaData object:

  • String specifying a sample name

  • Cell array of strings specifying sample names

  • Positive integer

  • Vector of positive integers

  • Logical vector


New sample names for specific names within a MetaData object, specified by one of the following:

  • Numeric vector

  • String or cell array of strings

  • String, which sampleNames uses as a prefix for the sample or feature names, with numbers appended to the prefix

  • Logical true or false (default). If true, sampleNames assigns unique names using the format Sample1, Sample2, etc.

The number of names in NewSamFeatNames must equal the number of samples specified by Subset.

Output Arguments


Cell array of strings specifying all or some of the sample names in a MetaData object. The sample names are also the row names of the VarValues dataset array in the MetaData object.


Object of the class, returned after replacing specific sample names.


Construct a MetaData object, and then retrieve the sample names from it:

% Import package to make constructor function
% available
% Construct MetaData object from .txt file
MDObj2 = MetaData('File', 'mouseSampleData.txt', 'VarDescChar', '#');
% Retrieve the sample names
SNames = sampleNames(MDObj2)

See Also

| | |

How To

Was this topic helpful?