IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
classes2legends.m
Go to the documentation of this file.
1 %> @ingroup conversion classlabelsgroup
2 %>@file
3 %>@brief Makes legend cell based on existing classes and class labels
4 %
5 %> @param Y classes vector
6 %> @param classlabels Class labels
7 %> @return A cell containing the legend strings
8 function legends = classes2legends(Y, classlabels)
9 
10 if nargin < 2 || isempty(classlabels)
11  classlabels = cell(1, max(Y)+1);
12  for i = 1:max(Y)+1
13  classlabels{i} = ['Class ', int2str(i-1)];
14  end;
15 end;
16 
17 uy = unique(Y);
18 uy1 = uy(uy < 0);
19 nuy1 = numel(uy1);
20 clneg = cell(1, nuy1);
21 for i = 1:nuy1
22  clneg{i} = get_negative_meaning(uy1(i));
23 end;
24 
25 legends = [clneg, classlabels{unique(Y(Y >= 0))+1}];
26 
function classes2legends(in Y, in classlabels)
function get_negative_meaning(in x)