IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
renumber_vector_idooo.m
Go to the documentation of this file.
1 %>@ingroup conversion classlabelsgroup
2 %>@file
3 %>@brief Renumbers vector in descending order of occurences of its elements. Leaves elements which are <= 0 alone.
4 %>
5 %> Re-numbering occurs so as to remove gaps in the original sequence.
6 %>
7 %> @warning Operates zero-based
8 %>
10 %
11 %> @param y
12 %> @return <code>[z]</code> or <code>[z, neworder]</code>
13 function varargout = renumber_vector_idooo(y)
14 
15 y = y(:);
16 
17 b_obsidxs = y >= 0;
18 
19 y2 = y(b_obsidxs);
20 
21 nums = unique(y2);
22 counts = diff(find([1, diff(sort(y2')), 1])); % Finds how many times each number appears
23 [dummy, neworder] = sort(counts, 'descend');
24 
25 
26 z2 = y2;
27 
28 for i = 1:numel(neworder)
29  z2(y2 == nums(neworder(i))) = nums(i); %i-1;
30 end;
31 
32 z = y;
33 z(b_obsidxs) = z2';
34 
35 if nargout == 1
36  varargout = {z};
37 elseif nargout == 2
38  varargout = {z, neworder};
39 end;
Assign classes from one data column from an irdata_clus object.
function renumber_vector_idooo(in y)
Analysis Session (AS) base class.
Definition: as.m:6
Image map.
Definition: vis_image.m:4
Image map for non-ordered, discrete features (e.g. from clustering)
Definition: vis_image_cat.m:4