Mercurial > hg > camir-aes2014
comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_ind2sub.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function Subs = som_ind2sub(msize,inds) | |
2 | |
3 %SOM_IND2SUB Map grid subscripts from linear index. | |
4 % | |
5 % Subs = som_ind2sub(msize,inds) | |
6 % | |
7 % sub = som_ind2sub([10 15],44); | |
8 % sub = som_ind2sub(sMap,44); | |
9 % sub = som_ind2sub(sMap.msize,44); | |
10 % Subs = som_ind2sub([10 15],[44 13 91]'); | |
11 % | |
12 % Input and output arguments: | |
13 % msize (struct) map or topology struct | |
14 % (vector) size 1 x m, specifies the map grid size | |
15 % inds (vector) size n x 1, linear indeces of n map units | |
16 % | |
17 % Subs (matrix) size n x m, the subscripts | |
18 % | |
19 % See also SOM_SUB2IND. | |
20 | |
21 % Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Vesanto | |
22 % http://www.cis.hut.fi/projects/somtoolbox/ | |
23 | |
24 % Version 2.0beta juuso 300798 | |
25 | |
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
27 | |
28 if isstruct(msize), | |
29 if strcmp(msize.type,'som_map'), msize = msize.topol.msize; | |
30 elseif strcmp(msize.type,'som_topol'), msize = msize.msize; | |
31 else error('Invalid first argument.'); end | |
32 end | |
33 | |
34 n = length(msize); | |
35 k = [1 cumprod(msize(1:end-1))]; | |
36 inds = inds - 1; | |
37 for i = n:-1:1, | |
38 Subs(:,i) = floor(inds/k(i))+1; | |
39 inds = rem(inds,k(i)); | |
40 end | |
41 | |
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |