wolffd@0: function varargout = mirspread(orig,varargin) wolffd@0: % S = mirspread(x) calculates the spread of x, which can be either: wolffd@0: % - a spectrum (spectral spread), wolffd@0: % - an envelope (temporal spread), or wolffd@0: % - any histogram. wolffd@0: wolffd@0: wolffd@0: varargout = mirfunction(@mirspread,orig,varargin,nargout,struct,@init,@main); wolffd@0: wolffd@0: wolffd@0: function [x type] = init(x,option) wolffd@0: if not(isamir(x,'mirdata')) || isamir(x,'miraudio') wolffd@0: x = mirspectrum(x); wolffd@0: end wolffd@0: type = 'mirscalar'; wolffd@0: wolffd@0: wolffd@0: function S = main(x,option,postoption) wolffd@0: if iscell(x) wolffd@0: x = x{1}; wolffd@0: end wolffd@0: y = peaksegments(@spread,get(x,'Data'),... wolffd@0: get(x,'Pos'),... wolffd@0: get(mircentroid(x),'Data')); wolffd@0: if isa(x,'mirspectrum') wolffd@0: t = 'Spectral spread'; wolffd@0: elseif isa(x,'mirenvelope') wolffd@0: t = 'Temporal spread'; wolffd@0: else wolffd@0: t = ['Spread of ',get(x,'Title')]; wolffd@0: end wolffd@0: S = mirscalar(x,'Data',y,'Title',t); wolffd@0: wolffd@0: wolffd@0: function s = spread(d,p,c) wolffd@0: s = sqrt( sum((p-c).^2.*d) ) ./ sum(d);