Keywords: Amplitude & phase vs frequency for a 3-term boxcar filter.gif en These graphs depict the same transfer function as File Frequency response of 3-term boxcar filter gif But here the amplitude is a signed quantity And where it is negative the quantity Ï has been added to the phase plot before computing the w principal value The purpose is to illustrate the linear-phase property of the FIR filter 2014-04-07 11 49 42 own Bob K Octave script <source lang Matlab > graphics_toolkit gnuplot N 256; h 1 1 1/3; impulse response H fftshift fft h N ; samples of DTFT abscissa -N/2 N/2-1 2 pi/N; normalized frequency Specify the bins that are to show a negative amplitude L floor N/6 ; negate 1+ 0 L N- 0 L-1 ; amplitude abs H ; amplitude negate -amplitude negate ; H negate -H negate ; compensate the phase of those bins phase angle H ; figure subplot 2 1 1 plot abscissa amplitude ; hold on plot abscissa zeros 1 N 'color' 'black' draw x-axis xlim -pi pi ylim - 4 1 2 set gca 'XTick' -pi -2 pi/3 0 2 pi/3 pi set gca 'YTick' - 2 0 2 4 6 8 1 grid 'on' xlabel '\leftarrow Frequency \omega radians/sample \rightarrow' ylabel 'Amplitude' set gca 'XTickLabel' '-\pi'; '-2\pi/3'; '0'; '2\pi/3'; '\pi'; 'interpreter' 'tex' set gca 'YTickLabel' '-0 2'; '0'; '0 2'; '0 4'; '0 6'; '0 8'; '1 0'; title 'Frequency response of 3-term boxcar filter' 'fontsize' 12 Gnuplot bug Without the following command the title gets cropped out of the figure But this command also causes subplot 1 to have less height than subplot 2 set gca 'position' get gca 'position' - 0 0 0 0 02 subplot 2 1 2 plot abscissa phase ; xlim -pi pi ylim -pi pi set gca 'XTick' -pi -2 pi/3 0 2 pi/3 pi set gca 'YTick' -pi -2 -1 0 1 2 pi grid 'on' Gnuplot bug xlabel gets cropped out of the figure xlabel '\leftarrow Frequency \omega radians/sample \rightarrow' ylabel 'Phase radians ' set gca 'XTickLabel' '-\pi'; '-2\pi/3'; '0'; '2\pi/3'; '\pi'; 'interpreter' 'tex' set gca 'YTickLabel' '-\pi'; '-2'; '-1'; '0'; '1'; '2'; '\pi'; 'interpreter' 'tex' </source> cc-zero Uploaded with UploadWizard Phase plots Bode plots |