1 ## Copyright (C) 2005 Michel D. Schmid <michaelschmid@users.sourceforge.net>
4 ## This program is free software; you can redistribute it and/or modify it
5 ## under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
9 ## This program is distributed in the hope that it will be useful, but
10 ## WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ## General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; see the file COPYING. If not, see
16 ## <http://www.gnu.org/licenses/>.
19 ## @deftypefn {Function File} {}@var{pn} = trastd (@var{p},@var{meanp},@var{stdp})
20 ## @code{trastd} preprocess additional data for neural network simulation.
23 ## @code{p} : test input data
24 ## @code{meanp}: vector with standardization parameters of prestd(...)
25 ## @code{stdp} : vector with standardization parameters of prestd(...)
27 ## meanp = [2.5; 6.5];
28 ## stdp = [1.2910; 1.2910];
31 ## pn = trastd(p,meanp,stdp);
36 ## @seealso{prestd, poststd}
38 ## Author: Michel D. Schmid
40 function [Pn] = trastd(Pp,meanp,stdp)
42 ## check number of inputs
43 error(nargchk(3,3,nargin));
46 [nRows,nColumns]=size(Pp);
47 rowOnes = ones(1,nColumns);
49 ## now set all standard deviations which are zero to 1
50 [nRowsII, nColumnsII] = size(stdp);
51 rowZeros = zeros(nRowsII,1);
52 findZeros = find(stdp==0);
53 rowZeros(findZeros)=1;
56 if ( sum(equal) != 0 )
57 warning("Some standard deviations are zero. Those inputs won't be transformed.");
58 meanp = meanp.*nequal;
59 stdp = stdp.*nequal + 1*equal;
62 Pn = (Pp-meanp*rowOnes)./(stdp*rowOnes);
67 ## >> mInput = [1 2 3 4; 5 6 7 8]
74 ## >> [pn,meanp,stdp] = prestd(mInput)
78 ## -1.1619 -0.3873 0.3873 1.1619
79 ## -1.1619 -0.3873 0.3873 1.1619