tomwalters@0: % method of class @signal tomwalters@0: % function sig=expand(sig,newlength,[value]) tomwalters@0: % tomwalters@0: % makes the signal longer (or shorter) by appending values with the value value tomwalters@0: % if time is negative, then expand it to the front by filling the first time with value tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % sig: original @signal tomwalters@0: % newlength: the new length of the signal tomwalters@0: % value: value, with wich the new part is filled [0] tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % time: time, when signal is bigger 0 for first time 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 tomwalters@0: tomwalters@0: function sig=expand(a,newlength,value) tomwalters@0: tomwalters@0: lenalt=getlength(a); tomwalters@0: sig=a; % erst mal eine Kopie des Signals tomwalters@0: sr=getsr(a); tomwalters@0: if newlength < 0 % aha, länger machen mit vorne auffüllen tomwalters@0: lenneu=lenalt-newlength; % denn die newlength ist ja negativ tomwalters@0: temp=a.werte; tomwalters@0: tomwalters@0: start=time2bin(a,-newlength); tomwalters@0: stop=time2bin(a,lenneu); tomwalters@0: tomwalters@0: neuevals=ones(1,stop)*value;% erst alle mit den gewünschten Werten belegen tomwalters@0: bla=time2bin(a,lenalt); tomwalters@0: neuevals(start+1:stop)=temp(1:bla); % dann mit dem alten Signal überschreiben tomwalters@0: tomwalters@0: sig.werte(1:stop)=neuevals(1:stop); tomwalters@0: tomwalters@0: else % positive neue Länge tomwalters@0: if lenalt>=newlength %nothing to do tomwalters@0: return; tomwalters@0: end tomwalters@0: start=time2bin(a,lenalt); tomwalters@0: stop=time2bin(a,newlength); tomwalters@0: sig.werte(start:stop)=value; tomwalters@0: end tomwalters@0: tomwalters@0: