tomwalters@0: % method of class @signal tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % bleeck@3: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: function [val,hoch,breit,widthvals]=qvalue(sig,where,howmuch) tomwalters@0: % usage: val=qvalue(sig,where,howmuch) tomwalters@0: % calculates the q-value, that is the hight divided by the width tomwalters@0: % of the signal at a point given by where (in seconds!) tomwalters@0: % howmuch is the indicator, how much the signal must be dropped 0.5 or such tomwalters@0: % returns the width in seconds, or 0, when the signal does not reach the value tomwalters@0: % widthvals has two x-values: where the width hits the signal tomwalters@0: tomwalters@0: vals=sig.werte; tomwalters@0: nr_bin=time2bin(sig,where); tomwalters@0: nr_values=getnrpoints(sig); tomwalters@0: howmuchdecrease=vals(nr_bin)*(1-howmuch); % value at the desired point tomwalters@0: val=0; tomwalters@0: hoch=0; tomwalters@0: breit=0; tomwalters@0: widthvals(1)=-inf; tomwalters@0: widthvals(2)=inf; tomwalters@0: tomwalters@0: int_time_up=nr_values+1; tomwalters@0: for i=nr_bin:nr_values tomwalters@0: if vals(i)< howmuchdecrease tomwalters@0: int_time_up=i; tomwalters@0: widthvals(1)=i; tomwalters@0: break; tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: int_time_down=0; tomwalters@0: for i=nr_bin:-1:1 tomwalters@0: if vals(i)< howmuchdecrease tomwalters@0: int_time_down=i; tomwalters@0: widthvals(2)=i; tomwalters@0: break; tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: if int_time_down==0 | int_time_up==nr_values tomwalters@0: hoch=vals(nr_bin); tomwalters@0: breit=1000000; tomwalters@0: val=hoch/breit; tomwalters@0: widthvals(1)=0; widthvals(2)=0; tomwalters@0: return; tomwalters@0: end tomwalters@0: tomwalters@0: time_up=bin2time(sig,int_time_up); tomwalters@0: time_down=bin2time(sig,int_time_down); tomwalters@0: tomwalters@0: hoch=vals(nr_bin); tomwalters@0: breit=time_up-time_down; tomwalters@0: if breit>0 tomwalters@0: val=hoch/breit; tomwalters@0: else tomwalters@0: vals=0; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: