Mercurial > hg > aimmat
view aim-mat/tools/@signal/expand.m @ 0:74dedb26614d
Initial checkin of AIM-MAT version 1.5 (6.4.2011).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 12:32:31 +0100 |
parents | |
children | 20ada0af3d7d |
line wrap: on
line source
% method of class @signal % function sig=expand(sig,newlength,[value]) % % makes the signal longer (or shorter) by appending values with the value value % if time is negative, then expand it to the front by filling the first time with value % % INPUT VALUES: % sig: original @signal % newlength: the new length of the signal % value: value, with wich the new part is filled [0] % % RETURN VALUE: % time: time, when signal is bigger 0 for first time % % (c) 2003-2008, University of Cambridge, Medical Research Council % Maintained by Tom Walters (tcw24@cam.ac.uk), written by Stefan Bleeck (stefan@bleeck.de) % http://www.pdn.cam.ac.uk/cnbh/aim2006 % $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $ % $Revision: 585 $ function sig=expand(a,newlength,value) lenalt=getlength(a); sig=a; % erst mal eine Kopie des Signals sr=getsr(a); if newlength < 0 % aha, länger machen mit vorne auffüllen lenneu=lenalt-newlength; % denn die newlength ist ja negativ temp=a.werte; start=time2bin(a,-newlength); stop=time2bin(a,lenneu); neuevals=ones(1,stop)*value;% erst alle mit den gewünschten Werten belegen bla=time2bin(a,lenalt); neuevals(start+1:stop)=temp(1:bla); % dann mit dem alten Signal überschreiben sig.werte(1:stop)=neuevals(1:stop); else % positive neue Länge if lenalt>=newlength %nothing to do return; end start=time2bin(a,lenalt); stop=time2bin(a,newlength); sig.werte(start:stop)=value; end