Example: Compensating for Group Delays When Analyzing Data

Comparing filtered with unfiltered data might be easier if you delay the unfiltered signal by the filter's group delay. For example, suppose you use the code below to filter x and produce y.

tx = 0:4; % Times for data samples
x = [0 1 1 1 1]'; % Binary data samples
% Filter the data and use a delay of 2 seconds.
delay = 2;
[y,ty] = rcosflt(x,1,8,'fir',.3,delay);

Here, the elements of tx and ty represent the times of each sample of x and y, respectively. However, y is delayed relative to x, so corresponding elements of x and y do not have the same time values. Plotting y against ty and x against tx is less useful than plotting y against ty and x against a delayed version of tx.

% Top plot
subplot(2,1,1), plot(tx,x,'*',ty,y);
legend('Data','Filtered data');
title('Data with No Added Delay');
% Bottom plot delays tx.
subplot(2,1,2), plot(tx+delay,x,'*',ty,y);
legend('Data','Filtered data');
title('Data with an Added Delay');

For another example of compensating for group delay, see the raised-cosine filter demo by typing playshow rcosdemo.


© 1994-2005 The MathWorks, Inc.