IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
data_split_groups.m
Go to the documentation of this file.
1 %> @ingroup datasettools
2 %> @file
3 %> @brief Splits data according to groups. Returns an array of datasets.
4 %>
5 
6 %> @param data irdata object
7 %>
8 %> @return <em>[pieces]</em> or <em>[pieces, map]</em>. @c pieces: array of irdata objects; @c map cell array of vectors containing the
9 %> indexes of the rows in the original dataset that went to each element of piece.
10 function varargout = data_split_groups(data)
11 
12 if isempty(data.groupcodes)
13  irerror('Dataset groupcodes is empty, cannot split dataset based on groups!');
14 end;
15 
16 for i = data.no_groups:-1:1 % Backwards to allocate at once
17  obsmaps{i} = data.get_obsidxs_from_groupidxs(i);
18 end;
19 out = data.split_map(obsmaps);
20 
21 if nargout == 1
22  varargout = {out};
23 else
24  varargout = {out, obsmaps};
25 end;
function irerror(in s)
Dataset class.
Definition: irdata.m:30
function data_split_groups(in data)