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