Home > FMAToolbox > General > ZeroToOne.m

ZeroToOne

PURPOSE ^

ZeroToOne - Normalize values in [0,1].

SYNOPSIS ^

function [x,varargout] = ZeroToOne(x,varargin)

DESCRIPTION ^

ZeroToOne - Normalize values in [0,1].

  USAGE

    [y,b0,b1...] = ZeroToOne(x,a0,a1,...)

    x              array to normalize
    a0...          additional inputs to transform using the same
                   scale as x

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x,varargout] = ZeroToOne(x,varargin)
0002 
0003 %ZeroToOne - Normalize values in [0,1].
0004 %
0005 %  USAGE
0006 %
0007 %    [y,b0,b1...] = ZeroToOne(x,a0,a1,...)
0008 %
0009 %    x              array to normalize
0010 %    a0...          additional inputs to transform using the same
0011 %                   scale as x
0012 
0013 % Copyright (C) 2008-2011 by Michaƫl Zugaro
0014 %
0015 % This program is free software; you can redistribute it and/or modify
0016 % it under the terms of the GNU General Public License as published by
0017 % the Free Software Foundation; either version 3 of the License, or
0018 % (at your option) any later version.
0019 
0020 if nargin < 1,
0021     error('Incorrect number of parameters (type ''help <a href="matlab:help ZeroToOne">ZeroToOne</a>'' for details).');
0022 end
0023 
0024 if nargin ~= nargout,
0025     error('Different numbers of input and output parameters (type ''help <a href="matlab:help ZeroToOne">ZeroToOne</a>'' for details).');
0026 end
0027 
0028 m = min(x);
0029 M = max(x);
0030 x = (x-m)/(M-m);
0031 
0032 for i = 1:nargin-1,
0033     varargout{i} = (varargin{i}-m)/(M-m);
0034 end

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005