annotate aim-mat/tools/@signal/qvalue2.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % method of class @signal
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
bleeck@3 8 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 9 % (c) 2011, University of Southampton
bleeck@3 10 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 11 % download of current version is on the soundsoftware site:
bleeck@3 12 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 13 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 14
tomwalters@0 15 function [val,height,width,widthvals,base_peak_y]=qvalue2(sig,where)
tomwalters@0 16 % similar to qvalue, but returns the value of height divided by width
tomwalters@0 17 % when height is calculated from maximum to the nearest minimum
tomwalters@0 18
tomwalters@0 19
tomwalters@0 20 vals=sig.werte;
tomwalters@0 21 nr_bin=time2bin(sig,where);
tomwalters@0 22 nr_values=getnrpoints(sig);
tomwalters@0 23
tomwalters@0 24 [maxpos,minpos,maxs,mins]=getminmax(sig);
tomwalters@0 25
tomwalters@0 26 [pos_min_left,minval_left]=getminimumleftof(where,maxpos,minpos,maxs,mins);
tomwalters@0 27 [pos_min_right,minval_right]=getminimumrightof(where,maxpos,minpos,maxs,mins);
tomwalters@0 28
tomwalters@0 29 if isempty(pos_min_left)
tomwalters@0 30 pos_min_left=0;
tomwalters@0 31 minimal_left=gettimevalue(sig,pos_min_left);
tomwalters@0 32 end
tomwalters@0 33 if isempty(pos_min_right)
tomwalters@0 34 pos_min_right=getmaximumtime(sig);
tomwalters@0 35 minval_right=gettimevalue(sig,pos_min_right);
tomwalters@0 36 end
tomwalters@0 37
tomwalters@0 38 if minval_left > minval_right
tomwalters@0 39 new_height=minval_left;
tomwalters@0 40 pos_left=pos_min_left;
tomwalters@0 41 widthvals(1)=pos_left;
tomwalters@0 42
tomwalters@0 43 pos_right=nr_values+1;
tomwalters@0 44 for i=nr_bin:nr_values
tomwalters@0 45 if vals(i)< minval_left
tomwalters@0 46 pos_right=bin2time(sig,i);
tomwalters@0 47 break;
tomwalters@0 48 end
tomwalters@0 49 end
tomwalters@0 50 else
tomwalters@0 51 new_height=minval_right;
tomwalters@0 52 pos_right=pos_min_right;
tomwalters@0 53 widthvals(2)=bin2time(sig,pos_right);
tomwalters@0 54
tomwalters@0 55 pos_left=0;
tomwalters@0 56 for i=nr_bin:-1:1
tomwalters@0 57 if vals(i)< minval_right
tomwalters@0 58 pos_left=bin2time(sig,i);
tomwalters@0 59 break;
tomwalters@0 60 end
tomwalters@0 61 end
tomwalters@0 62 end
tomwalters@0 63
tomwalters@0 64 width=pos_right-pos_left;
tomwalters@0 65 widthvals(1)=pos_left;
tomwalters@0 66 widthvals(2)=pos_right;
tomwalters@0 67
tomwalters@0 68 height=gettimevalue(sig,where)-new_height;
tomwalters@0 69
tomwalters@0 70 base_peak_y=new_height;
tomwalters@0 71
tomwalters@0 72
tomwalters@0 73 val=height/width;
tomwalters@0 74
tomwalters@0 75
tomwalters@0 76
tomwalters@0 77