1 function newexpr=initnoise(noise);
\r
2 % Used to initialize noise object. If an object is supplied, it will be returned without
\r
3 % modifications. If a double is supplied, a new 'gauss' object will be generated.
\r
5 % Syntax: (* = optional)
\r
7 % obj = initnoise(covariance);
\r
8 % obj = initnoise(variance);
\r
9 % obj = initnoise(noiseobj);
\r
14 % A covariance matrix, that will be sent to the 'gauss' constructor, to create a new
\r
15 % normally distributed noise object.
\r
17 % A vector containing the diagonal of a covariance matrix, that will be sent to the
\r
18 % 'gauss' constructor, to create a new normally distributed noise object.
\r
20 % Will be returned without modifications.
\r
25 % The resulting noise object.
\r
27 % Toolbox for nonlinear filtering.
\r
28 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
30 % This program is free software; you can redistribute it and/or
\r
31 % modify it under the terms of the GNU General Public License
\r
32 % as published by the Free Software Foundation; either version 2
\r
33 % of the License, or (at your option) any later version.
\r
35 % This program is distributed in the hope that it will be useful,
\r
36 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
37 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
38 % GNU General Public License for more details.
\r
40 % You should have received a copy of the GNU General Public License
\r
41 % along with this program; if not, write to the Free Software
\r
42 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
46 if size(noise,1)==size(noise,2)
\r
47 % A covariance matrix was supplied
\r
48 newexpr=gauss(noise);
\r
50 if min(size(noise,1),size(noise,2))>1
\r
51 error('Invalid variance vector');
\r
53 newexpr=gauss(diag(noise));
\r