Monday, March 26, 2018

filters - Plot the frequency response of MTI delay line canceller using Octave


I try to plot the frequency response of the delay line canceller (FIR filter which used for MTI).


The delay line canceller has the following structure:


              +-----+
| |
x [k] >---+---| T |
| | |
| +-----+

| |
| +-----+
| | |
| |x -1 |
| | |
| +-----+
| |
| +-----+
| | ___ |
\---| \ |---> y [k]

| /__ |
+-----+

Its frequency response is well known (Pg 20) and equal:


$$H(\omega) = 2 \cdot \left|\sin (\frac{\omega \cdot T} {2})\right| \tag{1}$$


I also try obtain frequency response of the canceller using algorithm which described on this question:


$$y [k] = x [k] - x [k - 1] \tag{2}$$


$$Y (z) = X (z) - X (z) z ^{-1} \tag {3}$$


$$ H(z) = 1 - z^{-1} \tag{4}$$


Now I try to plot (using GNU Octave) both of responses (1) and (4).



w = linspace (0, 2 * pi, 100);
z = exp (-j .* w);

H_z = 1 - z .^ -1;
H_w = 2.0 * abs (sin (w / 2) );

hold ("on");
plot (w, H_z, "1", "linewidth", 2);
plot (w, H_w, "2", "linewidth", 2);
title ("Frequency response of the delay line canceler.");

set (gca, 'XTick', 0: pi / 2: 2 * pi)
set (gca, 'XTickLabel',{'0', 'pi / 2', 'pi', '3 pi / 2','2 pi'})
xlabel ("Angular frequency.");
ylabel ("Magnitude.");
legend ("H (z)", 'H (\omega)');

I expect that they will be the same, but they are different.


enter image description here


Where is my mistake?


P.S. If I add modulus for (4) (like: H_z = abs (1 - z .^ -1);) they will became the same.




Answer



Magnitude |H(z)| is always defined as an absolute value of your transfer function H(z) values which are complex. What you are plotting is the vector that contains complex numbers. You need to take their absolute value and that will give you magnitude.


If you call the angle function then you are going to get phase. Transfer function H(z) is always complex. Try to print values of real(H_z) and imag(H_z), then you will see real and imaginary values of $H(z)$. Now magnitude |H(z)| is sqrt(real * real + imag * imag) for every sample...


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...