annotate aim-mat/tools/@signal/average.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 % function [meansig,stdsig]=average(sig,[t_start],[t_stop])
tomwalters@0 3 % calculates the average value of the signal
tomwalters@0 4 %
tomwalters@0 5 % INPUT VALUES:
tomwalters@0 6 % sig: original @signal
tomwalters@0 7 % t_start: start time in seconds [0]
tomwalters@0 8 % t_stop: stop time in seconds [getlength(sig)]
tomwalters@0 9 %
tomwalters@0 10 % RETURN VALUE:
tomwalters@0 11 % meansig: mean value of the signal
tomwalters@0 12 % stdsug: standart deviation
tomwalters@0 13 %
bleeck@3 14 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 15 % (c) 2011, University of Southampton
bleeck@3 16 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 17 % download of current version is on the soundsoftware site:
bleeck@3 18 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 19 % documentation and everything is on http://www.acousticscale.org
bleeck@3 20
tomwalters@0 21
tomwalters@0 22 function [meana,stda]=average(sig,t_start,t_stop)
tomwalters@0 23
tomwalters@0 24
tomwalters@0 25 if nargin < 2
tomwalters@0 26 t_start=getminimumtime(sig);
tomwalters@0 27 end
tomwalters@0 28 if nargin < 3
tomwalters@0 29 t_stop=t_start+getlength(sig);
tomwalters@0 30 end
tomwalters@0 31
tomwalters@0 32 intstart=time2bin(sig,t_start);
tomwalters@0 33 intstop=time2bin(sig,t_stop);
tomwalters@0 34
tomwalters@0 35 if intstart==0
tomwalters@0 36 intstart=1;
tomwalters@0 37 end
tomwalters@0 38
tomwalters@0 39 if intstart>intstop
tomwalters@0 40 error('signal::average: stoptime < starttime');
tomwalters@0 41 end
tomwalters@0 42
tomwalters@0 43
tomwalters@0 44 s=sig.werte(intstart:intstop);
tomwalters@0 45 if max(size(s))>1
tomwalters@0 46 meana=mean(s);
tomwalters@0 47 stda=std(s);
tomwalters@0 48 else
tomwalters@0 49 meana=s;
tomwalters@0 50 stda=0;
tomwalters@0 51 end