wolffd@0: function varargout = mirskewness(orig,varargin) wolffd@0: % s = skewness(x) calculates the skewness of x, showing the (lack of) wolffd@0: % symmetry of the curve. wolffd@0: % x can be either: wolffd@0: % - a spectrum (spectral skewness), wolffd@0: % - an envelope (temporal skewness), or wolffd@0: % - any histogram. wolffd@0: wolffd@0: wolffd@0: varargout = mirfunction(@mirskewness,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(@skewness,get(x,'Data'),... wolffd@0: get(x,'Pos'),... wolffd@0: get(mircentroid(x),'Data'),... wolffd@0: get(mirspread(x),'Data')); wolffd@0: if isa(x,'mirspectrum') wolffd@0: t = 'Spectral skewness'; wolffd@0: elseif isa(x,'mirenvelope') wolffd@0: t = 'Temporal skewness'; wolffd@0: else wolffd@0: t = ['Skewness of ',get(x,'Title')]; wolffd@0: end wolffd@0: s = mirscalar(x,'Data',y,'Title',t,'Unit',''); wolffd@0: wolffd@0: wolffd@0: function s = skewness(d,p,c,sp) wolffd@0: s = sum((p-c).^3.*d) ./ sum(d) ./ sp.^3;