Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@math/spflat.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 % spflat measures the flatness of a given spectrum | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: spflat measures the flatness of a given spectrum using the | |
5 % spectral flatness measure method reported in [1]. It outputs the spectral | |
6 % flatness coefficient: | |
7 % | |
8 % 0 <= sw <= 1 | |
9 % | |
10 % If the spectrum is peaky then sw is near 0. The more the spectrum is flat | |
11 % the more sw in near to 1. The sw coefficient is practically calculated by | |
12 % the ratio between geometric mean and arithmetic mean of the spectrum. | |
13 % | |
14 % CALL: | |
15 % | |
16 % sw = spflat(S) | |
17 % | |
18 % INPUTS: | |
19 % | |
20 % - S sample power spectrum. More than one sample spectrum can be | |
21 % input if they are combined in a single nxm matrix. The algorithm | |
22 % calculates sw for each spectrum. | |
23 % | |
24 % OUTPUT: | |
25 % | |
26 % - sw spectral flatness coefficient. If more than one spectrum | |
27 % are input sw is a row vector. | |
28 % | |
29 % REFERENCES: | |
30 % | |
31 % [1] S. M. Kay, Modern spectral estimation:Theory and Application, | |
32 % Prentice Hall, Englewood Cliffs (1988) ISBN-10: 0130151599. Pages | |
33 % ??. | |
34 % | |
35 % | |
36 % | |
37 % VERSION: $Id: spflat.m,v 1.2 2009/01/29 08:59:26 luigi Exp $ | |
38 % | |
39 % | |
40 % HISTORY: 28-01-2009 L Ferraioli | |
41 % Creation | |
42 % | |
43 % | |
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
45 function sw = spflat(S) | |
46 | |
47 % willing to work with columns | |
48 [a,b] = size(S); | |
49 if a>1 && b>1 | |
50 warning('Matlab:MultipleSpectra','A matrix of data was input; Spectral Flatness Coefficient will be calculated for each column') | |
51 else | |
52 if a<b | |
53 S = S.'; | |
54 end | |
55 end | |
56 Ns = size(S,1); | |
57 gmean = exp(sum(log(S))./Ns); | |
58 sw = gmean./mean(S); | |
59 | |
60 end |