comparison m-toolbox/test/utils/test_blwhitenoise.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % A test script for utils.math.blwhitenoise
2 %
3 % L. Ferraioli 18-11-08
4 %
5 % $Id: test_eigcsd.m,v 1.2 2009/06/10 16:12:06 luigi Exp $
6 %
7
8 %%
9
10 clear all
11
12 %%
13
14 % sampling frequency
15 fs = 10;
16 % higher bandwhidth frequency
17 fh = fs/2;
18 % lower bandwidth frequency
19 fl = 1e-3;
20 % number of data points
21 npts = 1e6;
22
23 % noise generation
24 wn = utils.math.blwhitenoise(npts,fs,fl,fh);
25
26 wnao = ao(tsdata(wn,fs));
27 % wnao.setNane('BLWN');
28
29 %% plot and statistics
30
31
32 iplot(wnao)
33
34 % Check histogram
35 wnao_hist = hist(wnao,plist('N',500,'Norm','true'));
36 wnao_norm = normdist(wnao,plist('N',500,'Norm','true'));
37
38 plpl = plist( ...
39 'Yscales', {'All','log'}, ...
40 'Legends', {'Histogram', 'Gaussian'});
41
42 iplot(wnao_hist,wnao_norm,plpl)
43
44 %% fft
45
46 WNf = fft(wnao);
47 iplot(WNf)
48
49 %% psd
50
51 % expected white noise at fs
52 f = [logspace(-5,fs/2,300)]';
53 expec = ao(plist('fsfcn', 'ones(size(f))', 'f', f));
54 expec = expec.*(2/fs);
55 WNxx = psd(wnao,plist('order',-1,'nfft',1e4));
56 iplot(WNxx,expec)
57
58 %% compare randn
59
60 aa = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', 1e5));
61
62 iplot(wnao)
63
64 % Check histogram
65 aa_hist = hist(aa,plist('N',500,'Norm','true'));
66 aa_norm = normdist(aa,plist('N',500,'Norm','true'));
67
68 plpl = plist( ...
69 'Yscales', {'All','log'}, ...
70 'Legends', {'Histogram', 'Gaussian'});
71
72 iplot(aa_hist,aa_norm,plpl)