Digital Signal Processing Reference
In-Depth Information
x1 = cos(2*pi*freq1*t);
x2 = cos(2*pi*freq2*t);
mytitle = ...
sprintf(A %d Hz sinusoid (.) and a %d Hz one (solid), ...
freq1, freq2);
start = 1;
last = show_num;
done = 0;
while (done ~=1)
plot(t(start:last), x1(start:last), k.-, t(start:last), ...
x2(start:last), g)
axis tight; % Make the axis look good
xlabel(Time (sec));
ylabel(Amplitude);
title(mytitle);
pause(1);
% Update array offsets
last = last + count;
start = start + count;
if (start >= length(x1))
done = 1;
end
if (last > length(x1))
last = length(x1);
end
end
2.9
Calculating Error
A common operation is to nd the dierence between two signals. For example, a
signal can be compressed, then uncompressed with a \lossy" compression algorithm.
(This is where some error in the signal is acceptable.) The amount of error between
the original and the reconstructed versions of the signal can be found by summing
the absolute values of the dierences. Is the absolute value function, abs, really
necessary? Consider the following two signals, x and y :
>> x = [1, 2, 5, 0, -2];
>> y = [-1, 4, 0, 5, -2];
Search WWH ::




Custom Search