annotate aim-mat/tools/@signal/gennoise.asv @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 74dedb26614d
children
rev   line source
tomwalters@0 1 % method of class @signal
tomwalters@0 2 % function sig=gennoise
tomwalters@0 3 % sig: original @signal with length and samplerate
tomwalters@0 4 %
tomwalters@0 5 % This function generates 1/f spatial noise, with a normal error
tomwalters@0 6 % distribution (the grid must be at least 10x10 for the errors to be normal).
tomwalters@0 7 % 1/f noise is scale invariant, there is no spatial scale for which the
tomwalters@0 8 % variance plateaus out, so the process is non-stationary.
tomwalters@0 9 %
tomwalters@0 10 % BETA defines the spectral distribution.
tomwalters@0 11 % Spectral density S(f) = N f^BETA
tomwalters@0 12 % (f is the frequency, N is normalisation coeff).
tomwalters@0 13 % BETA = 0 is random white noise.
tomwalters@0 14 % BETA -1 is pink noise
tomwalters@0 15 % BETA = -2 is Brownian noise
tomwalters@0 16 % The fractal dimension is related to BETA by, D = (6+BETA)/2
tomwalters@0 17 %
tomwalters@0 18 %
tomwalters@0 19 % RETURN VALUE:
tomwalters@0 20 % sig: @signal
tomwalters@0 21 %
tomwalters@0 22 % (c) 2007 ISVR University of Southampton
tomwalters@0 23 % Stefan Bleeck (bleeck@gmail.com)
tomwalters@0 24 % $Date: 2003/01/25 12:47:43 $
tomwalters@0 25 % $Revision: 1.4 $
tomwalters@0 26
tomwalters@0 27 % function sig=gennoise(sig,beta,rms_desired)
tomwalters@0 28 function sig=gennoise(sig,beta)
tomwalters@0 29
tomwalters@0 30 % if nargin<3
tomwalters@0 31 % rms_desired=-1; %
tomwalters@0 32 % end
tomwalters@0 33 if nargin<2
tomwalters@0 34 beta=0; %
tomwalters@0 35 end
tomwalters@0 36
tomwalters@0 37 sr=getsr(sig);
tomwalters@0 38 len=getnrpoints(sig);
tomwalters@0 39
tomwalters@0 40 dots=spatialPattern([1,len],beta);
tomwalters@0 41
tomwalters@0 42 sig=setvalues(sig,dots);
tomwalters@0 43 sig=setname(sig,sprintf('Noise with beta = %2.1f',beta));
tomwalters@0 44
tomwalters@0 45
tomwalters@0 46 % if rms_desired>=0
tomwalters@0 47 % sig=rms_desired*sig/rms(sig);
tomwalters@0 48 % end
tomwalters@0 49
tomwalters@0 50