wolffd@0
|
1 function varargout = mirskewness(orig,varargin)
|
wolffd@0
|
2 % s = skewness(x) calculates the skewness of x, showing the (lack of)
|
wolffd@0
|
3 % symmetry of the curve.
|
wolffd@0
|
4 % x can be either:
|
wolffd@0
|
5 % - a spectrum (spectral skewness),
|
wolffd@0
|
6 % - an envelope (temporal skewness), or
|
wolffd@0
|
7 % - any histogram.
|
wolffd@0
|
8
|
wolffd@0
|
9
|
wolffd@0
|
10 varargout = mirfunction(@mirskewness,orig,varargin,nargout,struct,@init,@main);
|
wolffd@0
|
11
|
wolffd@0
|
12
|
wolffd@0
|
13 function [x type] = init(x,option)
|
wolffd@0
|
14 if not(isamir(x,'mirdata')) || isamir(x,'miraudio')
|
wolffd@0
|
15 x = mirspectrum(x);
|
wolffd@0
|
16 end
|
wolffd@0
|
17 type = 'mirscalar';
|
wolffd@0
|
18
|
wolffd@0
|
19
|
wolffd@0
|
20 function s = main(x,option,postoption)
|
wolffd@0
|
21 if iscell(x)
|
wolffd@0
|
22 x = x{1};
|
wolffd@0
|
23 end
|
wolffd@0
|
24 y = peaksegments(@skewness,get(x,'Data'),...
|
wolffd@0
|
25 get(x,'Pos'),...
|
wolffd@0
|
26 get(mircentroid(x),'Data'),...
|
wolffd@0
|
27 get(mirspread(x),'Data'));
|
wolffd@0
|
28 if isa(x,'mirspectrum')
|
wolffd@0
|
29 t = 'Spectral skewness';
|
wolffd@0
|
30 elseif isa(x,'mirenvelope')
|
wolffd@0
|
31 t = 'Temporal skewness';
|
wolffd@0
|
32 else
|
wolffd@0
|
33 t = ['Skewness of ',get(x,'Title')];
|
wolffd@0
|
34 end
|
wolffd@0
|
35 s = mirscalar(x,'Data',y,'Title',t,'Unit','');
|
wolffd@0
|
36
|
wolffd@0
|
37
|
wolffd@0
|
38 function s = skewness(d,p,c,sp)
|
wolffd@0
|
39 s = sum((p-c).^3.*d) ./ sum(d) ./ sp.^3; |