No BSD License  

Highlights from
Generic Signal Class

from Generic Signal Class by Stefan Bleeck
A generic class that allows easy signal (data in time) managment

[val,hoch,breit,widthvals]=qvalue(sig,where,howmuch)
% method of class @signal
% 
%   INPUT VALUES:
%  
%   RETURN VALUE:
%
% 
% (c) 2003, University of Cambridge, Medical Research Council 
% Stefan Bleeck (stefan@bleeck.de)
% http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
% $Date: 2003/06/11 10:27:46 $
% $Revision: 1.4 $

function [val,hoch,breit,widthvals]=qvalue(sig,where,howmuch)
% usage: val=qvalue(sig,where,howmuch)
% calculates the q-value, that is the hight divided by the width
% of the signal at a point given by where (in seconds!)
% howmuch is the indicator, how much the signal must be dropped 0.5 or such
% returns the width in seconds, or 0, when the signal does not reach the value
% widthvals has two x-values: where the width hits the signal

vals=sig.werte;
nr_bin=time2bin(sig,where);
nr_values=getnrpoints(sig);
howmuchdecrease=vals(nr_bin)*(1-howmuch);   % value at the desired point
val=0;
hoch=0;
breit=0;
widthvals(1)=-inf;
widthvals(2)=inf;

int_time_up=nr_values+1;
for i=nr_bin:nr_values
    if vals(i)< howmuchdecrease
        int_time_up=i;
		widthvals(1)=i;
        break;
    end
end

int_time_down=0;
for i=nr_bin:-1:1
    if vals(i)< howmuchdecrease
        int_time_down=i;
		widthvals(2)=i;
        break;
    end
end

if int_time_down==0 | int_time_up==nr_values
    hoch=vals(nr_bin);
    breit=1000000;
    val=hoch/breit;
	widthvals(1)=0;	widthvals(2)=0;
    return;
end

time_up=bin2time(sig,int_time_up);
time_down=bin2time(sig,int_time_down);

hoch=vals(nr_bin);
breit=time_up-time_down;
if breit>0
	val=hoch/breit;	
else
	vals=0;
end




Contact us at files@mathworks.com