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