Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/welchscale.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 % WELCHSCALE scales the output of welch to be in the required units | |
2 % | |
3 % $Id: welchscale.m,v 1.9 2011/03/11 06:59:04 mauro Exp $ | |
4 % | |
5 | |
6 function [yy, dyy, info] = welchscale(xx, dxx, win, fs, norm, inunits) | |
7 | |
8 nfft = length(win); | |
9 S1 = sum(win); | |
10 S2 = sum(win.^2); | |
11 enbw = fs * S2 / (S1*S1); | |
12 | |
13 if isempty(norm) | |
14 norm = 'None'; | |
15 end | |
16 switch lower(norm) | |
17 case 'asd' | |
18 yy = sqrt(xx); | |
19 if isempty(dxx) | |
20 dyy = dxx; | |
21 else | |
22 dyy = 1./2./sqrt(xx) .* dxx; | |
23 end | |
24 info.units = inunits ./ unit('Hz^0.5'); | |
25 case 'psd' | |
26 yy = xx; | |
27 dyy = dxx; | |
28 info.units = inunits.^2/unit('Hz'); | |
29 case 'as' | |
30 yy = sqrt(xx * enbw); | |
31 if isempty(dxx) | |
32 dyy = dxx; | |
33 else | |
34 dyy = 1./2./sqrt(xx) .* dxx * enbw; | |
35 end | |
36 info.units = inunits; | |
37 case 'ps' | |
38 yy = xx * enbw; | |
39 dyy = dxx * enbw; | |
40 info.units = inunits.^2; | |
41 case 'none' | |
42 yy = xx; | |
43 dyy = dxx; | |
44 info.units = inunits; | |
45 otherwise | |
46 error('Unknown normalisation'); | |
47 end | |
48 | |
49 info.nfft = nfft; | |
50 info.enbw = enbw; | |
51 info.norm = norm; | |
52 | |
53 end | |
54 |