comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirspread.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function varargout = mirspread(orig,varargin)
2 % S = mirspread(x) calculates the spread of x, which can be either:
3 % - a spectrum (spectral spread),
4 % - an envelope (temporal spread), or
5 % - any histogram.
6
7
8 varargout = mirfunction(@mirspread,orig,varargin,nargout,struct,@init,@main);
9
10
11 function [x type] = init(x,option)
12 if not(isamir(x,'mirdata')) || isamir(x,'miraudio')
13 x = mirspectrum(x);
14 end
15 type = 'mirscalar';
16
17
18 function S = main(x,option,postoption)
19 if iscell(x)
20 x = x{1};
21 end
22 y = peaksegments(@spread,get(x,'Data'),...
23 get(x,'Pos'),...
24 get(mircentroid(x),'Data'));
25 if isa(x,'mirspectrum')
26 t = 'Spectral spread';
27 elseif isa(x,'mirenvelope')
28 t = 'Temporal spread';
29 else
30 t = ['Spread of ',get(x,'Title')];
31 end
32 S = mirscalar(x,'Data',y,'Title',t);
33
34
35 function s = spread(d,p,c)
36 s = sqrt( sum((p-c).^2.*d) ) ./ sum(d);