Home > data-analysis > manip > cstream > cstream_time_shift.m

cstream_time_shift

PURPOSE ^

SYNOPSIS ^

function newCstream = cstream_time_shift(cstream, offset)

DESCRIPTION ^

  this function shifts the whole cstream by an offset
 
   Input: cstream nd an offset in seconds; the offset can be both
   positive (moving forward) or negative (moving backward). 

   Output: a newCstream 

  this function is useful to shift the whole cstream

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 function newCstream = cstream_time_shift(cstream, offset)
0003 %
0004 %  this function shifts the whole cstream by an offset
0005 %
0006 %   Input: cstream nd an offset in seconds; the offset can be both
0007 %   positive (moving forward) or negative (moving backward).
0008 %
0009 %   Output: a newCstream
0010 %
0011 %  this function is useful to shift the whole cstream
0012 %
0013 %
0014 
0015 
0016 rate = cstream(2,1) - cstream(1,1); 
0017 n = round(abs(offset)/rate); 
0018 newCstream = zeros(size(cstream)); 
0019 newCstream(:,1) = cstream(:,1);
0020 if (offset > 0 ) 
0021     newCstream(n+1:end,2) = cstream(1:end-n,2); 
0022 elseif (offset < 0)
0023     newCstream(1:end-n,2) = cstream(n+1:end,2);
0024 end;
0025 
0026

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005