Dataset get: Difference between revisions
imported>Jeremy |
imported>Jeremy No edit summary |
||
Line 2: | Line 2: | ||
Get field/property values from a DataSet object. | Get field/property values from a DataSet object. | ||
===Synopsis=== | ===Synopsis=== | ||
value = get(x,'field',''vdim''); | :value = get(x,'field',''vdim,vset''); | ||
===Description=== | ===Description=== | ||
dataset/get is a depreciated function. See dataset/subsref for the preferred method of extracting values from a DataSet object. | dataset/get is a depreciated function. See [[dataset_subsref|dataset/subsref]] for the preferred method of extracting values from a DataSet object. | ||
The I/O for GET depends on whether the data are of class double or cell. The more common usage is when the data are of class double and this is discussed under subheading 1. In this case the data can be contained in a double array of 2 or higher modes/dimensions. Differences for data of class cell are discussed under subheading 2. | The I/O for GET depends on whether the data are of class double or cell. The more common usage is when the data are of class double and this is discussed under subheading 1. In this case the data can be contained in a double array of 2 or higher modes/dimensions. Differences for data of class cell are discussed under subheading 2. | ||
1) The following is used when the data field is a fixed-size array (.type = 'data' or 'image') | 1) The following is used when the data field is a fixed-size array (.type = 'data' or 'image') | ||
value = get(x,'field'); | * '''<tt>value = get(x,'field');</tt>''' | ||
For DataSet x this returns the value (value) of the property 'field'. This syntax is used for the following fields: | For DataSet x this returns the value (value) of the property 'field'. This syntax is used for the following fields: | ||
name: value is a char vector. | name: value is a char vector. | ||
Line 20: | Line 22: | ||
history: cell array of char (''e.g. ''char(get(h,'history'))) | history: cell array of char (''e.g. ''char(get(h,'history'))) | ||
datasetversion: dataset object version. | datasetversion: dataset object version. | ||
Example: | Example: get(x,'data(:,1)') %Extracts the first column of the double array. | ||
get(x,'data(:,1)') | |||
value = get(x,'field',''vdim''); | * '''<tt>value = get(x,'field',''vdim'');</tt>''' | ||
This syntax is used with the following fields: | This syntax is used with the following fields: | ||
include: value is row vector of indices for mode ''vdim''. | include: value is row vector of indices for mode ''vdim''. | ||
value = get(x,'field',''vdim,vset''); | |||
* '''<tt>value = get(x,'field',''vdim,vset'');</tt>''' | |||
Returns the value value for the property 'field' for the specified dimension/mode ''vdim ''and optional set ''vset ''{default: vset=1}. ''E.g. vset ''is used when multiple sets of labels are present in x. This syntax is used for the following fields: | Returns the value value for the property 'field' for the specified dimension/mode ''vdim ''and optional set ''vset ''{default: vset=1}. ''E.g. vset ''is used when multiple sets of labels are present in x. This syntax is used for the following fields: | ||
label: value is a char array with size(x.data,vdim) rows. | label: value is a char array with size(x.data,vdim) rows. | ||
Line 35: | Line 38: | ||
class: value is a row vector with size(x.data,vdim) integer elements. | class: value is a row vector with size(x.data,vdim) integer elements. | ||
classname: value is a char row vector. | classname: value is a char row vector. | ||
2) For cases when the data set consists of multiple matrices of variable length (''e.g. ''each data matrix | |||
value = get(x,'field'); | 2) For cases when the data set consists of multiple matrices of variable length (''e.g.'' each data matrix has the same number of columns but different numbers of rows: ''N<sub>1,i</sub>xN<sub>m</sub>, m = 2, ..., M; ''and ''N<sub>1,i</sub>≠N<sub>1,j</sub> ''for ''i≠j'') the field '.data' can contain a cell array and the field '.type' is 'batch'. The following are specific to GET when the data field is of class cell (.type = 'batch'). For fields not listed below use the I/O syntax listed under subheading 1. | ||
* '''<tt>value = get(x,'field');</tt>''' | |||
Returns the value value of the property 'field'. This syntax is used for the following fields: | Returns the value value of the property 'field'. This syntax is used for the following fields: | ||
type: value is 'batch'. | type: value is 'batch'. | ||
Line 43: | Line 48: | ||
get(x,'data{3}(:,1)') %extracts the first column of the third cell | get(x,'data{3}(:,1)') %extracts the first column of the third cell | ||
get(x,'data{2}') %extracts the entire contents of the second cell. | get(x,'data{2}') %extracts the entire contents of the second cell. | ||
value = get(x,'field',''vdim,vset''); | |||
* '''<tt>value = get(x,'field',''vdim,vset'');</tt>''' | |||
Returns the value value of the property 'field' for the specified dimension/mode ''vdim ''and optional set ''vset ''{default: vset=1}. ''E.g. vset ''is used when multiple sets of labels are present in x. This syntax is used for the following fields: | Returns the value value of the property 'field' for the specified dimension/mode ''vdim ''and optional set ''vset ''{default: vset=1}. ''E.g. vset ''is used when multiple sets of labels are present in x. This syntax is used for the following fields: | ||
axisscale: value is a row vector with size(x.data,vdim) real elements. For all but the first mode the I/O syntax is identical to that for data of class double discussed under subheading 1. For mode 1 vdim is either scalar value 1 (''i.e. ''vdim=1), or a two element vector with vdim(1)=1 and vdim(2)=i where ''i = 1, ..., N1''. | axisscale: value is a row vector with size(x.data,vdim) real elements. For all but the first mode the I/O syntax is identical to that for data of class double discussed under subheading 1. For mode 1 vdim is either scalar value 1 (''i.e. ''vdim=1), or a two element vector with vdim(1)=1 and vdim(2)=i where ''i = 1, ..., N1''. | ||
Line 49: | Line 55: | ||
get(x,'axisscale',1,2) extracts the entire cell array of axis scales for mode 1 from the second set | get(x,'axisscale',1,2) extracts the entire cell array of axis scales for mode 1 from the second set | ||
get(x,'axisscale',[1 3]) extracts the axis scales for mode 1 of the 3rd cell from the first set | get(x,'axisscale',[1 3]) extracts the axis scales for mode 1 of the 3rd cell from the first set | ||
===See Also=== | ===See Also=== | ||
[[datasetdemo]], [[dataset_set]], [[dataset_subsref]], [[dataset_explode]] | [[datasetdemo]], [[dataset_set]], [[dataset_subsref]], [[dataset_explode]] |
Latest revision as of 16:59, 8 October 2008
Purpose
Get field/property values from a DataSet object.
Synopsis
- value = get(x,'field',vdim,vset);
Description
dataset/get is a depreciated function. See dataset/subsref for the preferred method of extracting values from a DataSet object.
The I/O for GET depends on whether the data are of class double or cell. The more common usage is when the data are of class double and this is discussed under subheading 1. In this case the data can be contained in a double array of 2 or higher modes/dimensions. Differences for data of class cell are discussed under subheading 2.
1) The following is used when the data field is a fixed-size array (.type = 'data' or 'image')
- value = get(x,'field');
For DataSet x this returns the value (value) of the property 'field'. This syntax is used for the following fields:
name: value is a char vector. author: value is a char vector. date: value is a 6 element vector (see CLOCK). moddate: value is a 6 element vector (last modified date). type: value is either 'data' or 'image'. data: value is a double array. description: value is a char array. userdata: user defined. description: value is a char array. history: cell array of char (e.g. char(get(h,'history'))) datasetversion: dataset object version.
Example: get(x,'data(:,1)') %Extracts the first column of the double array.
- value = get(x,'field',vdim);
This syntax is used with the following fields:
include: value is row vector of indices for mode vdim.
- value = get(x,'field',vdim,vset);
Returns the value value for the property 'field' for the specified dimension/mode vdim and optional set vset {default: vset=1}. E.g. vset is used when multiple sets of labels are present in x. This syntax is used for the following fields:
label: value is a char array with size(x.data,vdim) rows. labelname: value is a char row vector. axisscale: value is a row vector with size(x.data,vdim) real elements. axisscalename: value is a char row vector. title: value is a char row vector. titlename: value is a char row vector. class: value is a row vector with size(x.data,vdim) integer elements. classname: value is a char row vector.
2) For cases when the data set consists of multiple matrices of variable length (e.g. each data matrix has the same number of columns but different numbers of rows: N1,ixNm, m = 2, ..., M; and N1,i≠N1,j for i≠j) the field '.data' can contain a cell array and the field '.type' is 'batch'. The following are specific to GET when the data field is of class cell (.type = 'batch'). For fields not listed below use the I/O syntax listed under subheading 1.
- value = get(x,'field');
Returns the value value of the property 'field'. This syntax is used for the following fields:
type: value is 'batch'. data: value is a cell array (extracts entire data set).
Example: get(x,'data{3}(:,1)') %extracts the first column of the third cell get(x,'data{2}') %extracts the entire contents of the second cell.
- value = get(x,'field',vdim,vset);
Returns the value value of the property 'field' for the specified dimension/mode vdim and optional set vset {default: vset=1}. E.g. vset is used when multiple sets of labels are present in x. This syntax is used for the following fields: axisscale: value is a row vector with size(x.data,vdim) real elements. For all but the first mode the I/O syntax is identical to that for data of class double discussed under subheading 1. For mode 1 vdim is either scalar value 1 (i.e. vdim=1), or a two element vector with vdim(1)=1 and vdim(2)=i where i = 1, ..., N1. Example: get(x,'axisscale',1,2) extracts the entire cell array of axis scales for mode 1 from the second set get(x,'axisscale',[1 3]) extracts the axis scales for mode 1 of the 3rd cell from the first set