IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
subsets2matrix.m
Go to the documentation of this file.
1 %> @ingroup conversion
2 %> @file
3 %> @brief Converts a cell of subsets into a matrix.
4 %>
5 %> If the subset size varies, fills in smaller subsets with NaN's
6 %> @sa log_fselrepeater
7 %
8 %> @param subsets as in log_fselrepeater::subsets
9 %> @return Matrix
10 function out = subsets2matrix(subsets)
11 nsub = numel(subsets);
12 numelmax = max(cellfun(@numel, subsets));
13 
14 out = NaN(nsub, numelmax);
15 
16 for i = 1:nsub
17  subset = subsets{i};
18  out(i, 1:numel(subset)) = subset(:);
19 end;