Mercurial > hg > camir-aes2014
annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/som_fillnans.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function sD = som_fillnans(sD,sM,bmus) |
wolffd@0 | 2 |
wolffd@0 | 3 % SOM_FILLNANS Replaces NaNs in the data matrix with values from |
wolffd@0 | 4 % SOM prototypes. |
wolffd@0 | 5 % |
wolffd@0 | 6 % sD = som_fillnans(sD,sM, [bmus]) |
wolffd@0 | 7 % |
wolffd@0 | 8 % sD (struct) data struct |
wolffd@0 | 9 % (matrix) size dlen x dim |
wolffd@0 | 10 % sM (struct) data struct, with .data of size dlen x dim |
wolffd@0 | 11 % (matrix) size dlen x dim, a matrix from which |
wolffd@0 | 12 % the values are taken from directly |
wolffd@0 | 13 % (struct) map struct: replacement values are taken from |
wolffd@0 | 14 % sM.codebook(bmus,:) |
wolffd@0 | 15 % [bmus] (vector) BMU for each data vector (calculated if not specified) |
wolffd@0 | 16 % |
wolffd@0 | 17 % See also SOM_MAKE. |
wolffd@0 | 18 |
wolffd@0 | 19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
wolffd@0 | 20 |
wolffd@0 | 21 if isstruct(sD), |
wolffd@0 | 22 [dlen dim] = size(sD.data); |
wolffd@0 | 23 nans = find(isnan(sD.data)); |
wolffd@0 | 24 else |
wolffd@0 | 25 [dlen dim] = size(sD); |
wolffd@0 | 26 nans = find(isnan(sD)); |
wolffd@0 | 27 end |
wolffd@0 | 28 |
wolffd@0 | 29 if nargin<3, |
wolffd@0 | 30 bmus = som_bmus(sM,sD); |
wolffd@0 | 31 end |
wolffd@0 | 32 |
wolffd@0 | 33 if isstruct(sM) & strcmp(sM.type,'som_map'), |
wolffd@0 | 34 sM = sM.codebook(bmus,:); |
wolffd@0 | 35 elseif isstruct(sM), |
wolffd@0 | 36 sM = sM.data(bmus,:); |
wolffd@0 | 37 else |
wolffd@0 | 38 sM = sM(bmus,:); |
wolffd@0 | 39 end |
wolffd@0 | 40 me = mean(sM); |
wolffd@0 | 41 |
wolffd@0 | 42 if any(size(sM) ~= [dlen dim]), |
wolffd@0 | 43 error('Invalid input arguments.') |
wolffd@0 | 44 end |
wolffd@0 | 45 |
wolffd@0 | 46 if isstruct(sD), |
wolffd@0 | 47 sD.data(nans) = sM(nans); |
wolffd@0 | 48 else |
wolffd@0 | 49 sD(nans) = sM(nans); |
wolffd@0 | 50 end |
wolffd@0 | 51 |
wolffd@0 | 52 return; |
wolffd@0 | 53 |
wolffd@0 | 54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
wolffd@0 | 55 |
wolffd@0 | 56 |