Fichier:Amplitude & phase vs frequency for 3-term boxcar filter.svg

Le contenu de la page n’est pas pris en charge dans d’autres langues.
Un livre de Wikilivres.

Fichier d’origine(Fichier SVG, nominalement de 435 × 400 pixels, taille : 20 kio)

Description

Description
English: 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 principal value). The purpose is to illustrate the linear-phase property of the FIR filter.
Русский: Амлитудно-частотная и фазовая характеристики фильтра с конечной импульсной характеристикой скользящего среднего
Date
Source Travail personnel
Auteur original: Bob K
vector version: Krishnavedala
Autorisation
(Réutilisation de ce fichier)
Creative Commons CC-Zero Ce fichier est disponible selon les termes de la licence Creative Commons CC0 Don universel au domaine public.
La personne qui a associé une œuvre avec cet acte l’a placée dans le domaine public en renonçant mondialement à tous ses droits sur cette œuvre en vertu des lois relatives au droit d’auteur, ainsi qu’à tous les droits juridiques connexes et voisins qu’elle possédait sur l’œuvre, sans autre limite que celles imposées par la loi. Vous pouvez copier, modifier, distribuer et utiliser cette œuvre, y compris à des fins commerciales, sans qu’il soit nécessaire d’en demander la permission.

Autres versions Ce fichier est dérivé de : Amplitude & phase vs frequency for a 3-term boxcar filter.gif
SVG information
InfoField
 
Le code de ce fichier SVG est valide.
 
Cette image vectorielle a été créée avec Python par Krishnavedala
Python source
InfoField
click to expand

This script is a translation of the original Octave script into Python, for the purpose of generating an SVG file to replace the GIF version.

import scipy
from scipy import signal
import numpy as np
from matplotlib import pyplot as plt

N = 256
h = np.array([1., 1., 1.]) / 3
H = scipy.fftpack.shift(scipy.fft(h, n=N), np.pi)
w = np.linspace(-N/2, N/2-1, num=N) * 2 * np.pi / N

amplitude = abs(H)
L = int(np.floor(N/6))
negate1 = np.array(range(L)) + 1
negate2 = N - np.array(range(L)) - 1
amplitude[negate1] = -amplitude[negate1]
amplitude[negate2] = -amplitude[negate2]
H[negate1] = -H[negate1]
H[negate2] = -H[negate2]

fig = plt.figure(figsize=[5,5])
plt.subplot(211)
plt.plot(w, amplitude, 'blue')
plt.grid(True)
plt.ylabel('Amplitude')
plt.xlim([-np.pi,np.pi])
plt.xticks([-np.pi, -2*np.pi/3,0,2*np.pi/3,np.pi], [])
plt.subplot(212)
plt.plot(w, np.angle(H), 'blue')
plt.grid(True)
plt.ylabel('Phase (radians)')
plt.xlabel('$\\longleftarrow$ Frequency ($\\omega$) (radians/sample) $\\longrightarrow$')
plt.xticks([-np.pi, -2*np.pi/3,0,2*np.pi/3,np.pi], ['-$\pi$','-2$\pi$/3','0','2$\pi$/3','$\pi$'])
plt.xlim([-np.pi,np.pi])
plt.yticks([-np.pi, -2,-1,0,1,2,np.pi], ['-$\pi$','-2','-1','0','1','2','$\pi$'])
plt.ylim([-np.pi,np.pi])
plt.subplots_adjust(hspace=0.1)
plt.savefig('Amplidue & phase vs frequency response of 3-term boxcar filter.svg', bbox_inches='tight', transparent=True)
Octave/gnuplot source
InfoField
click to expand
This script was derived from the original in order to address some GNUplot bugs: a missing title and two missing axis labels.  And to add an Octave print function, which creates an SVG file.  Alternatively, the gnuplot screen image has an export function that produces an SVG file, but the π characters aren't as professional-looking.  I think the resultant quality produced by this script is now better than the file produced by the Python script.
graphics_toolkit gnuplot
clear all; close all; clc
  
hfig = figure("position",[100 100 509 509]);

x1 = .12;               % left margin for name of Y-variable
x2 = .02;               % right margin
y1 = .10;               % bottom margin for ticks
y2 = .08;               % top margin for title
dy = .08;               % vertical space between rows

width = 1-x1-x2;
height= (1-y1-y2-dy)/2; % space allocated for each of 2 rows

x_origin = x1;
y_origin = 1;           % start at top of graph area
%=======================================================
  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);
%=======================================================
  y_origin = y_origin -y2 -height;        % position of top row
  subplot("position",[x_origin y_origin width height])
  plot(abscissa, amplitude, "linewidth", 2);
% Default xaxislocation is "bottom", which is where we want the tick labels.
% set(gca, "xaxislocation", "origin")
  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")

  ylabel("Amplitude")
% set(gca, "ticklabelinterpreter", "tex")	% tex is the default
  set(gca, "XTickLabel", ['-\pi'; '-2\pi/3'; '0'; '2\pi/3'; '\pi';])
  set(gca, "YTickLabel", ['-.2'; '0'; '.2'; '.4'; '.6'; '.8'; '1';])
  title("Frequency response of 3-term boxcar filter", "fontsize", 12)
%=======================================================
  y_origin = y_origin -dy -height;
  subplot("position",[x_origin y_origin width height])
  plot(abscissa, phase, "linewidth", 2);
  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")

  xlabel('\leftarrow Frequency (\omega) (radians/sample) \rightarrow')
  ylabel("Phase (radians)")
% set(gca, "ticklabelinterpreter", "tex")	% tex is the default
  set(gca, "XTickLabel", ['-\pi'; '-2\pi/3'; '0'; '2\pi/3'; '\pi';])
  set(gca, "YTickLabel", ['-\pi'; '-2'; '-1'; '0'; '1'; '2'; '\pi';])

% The print function results in nicer-looking "pi" symbols
% than the export function on the GNUPlot figure toolbar.
print(hfig,"-dsvg", "-S509,509","-color", ...
'C:\Users\BobK\Amplitude & phase vs frequency for a 3-term boxcar filter.svg')

Légendes

Ajoutez en une ligne la description de ce que représente ce fichier

Éléments décrits dans ce fichier

dépeint

image/svg+xml

9f3c3a071591f369e4e0d2c300c59f7bdf6e2841

20 378 octet

400 pixel

435 pixel

Historique du fichier

Cliquer sur une date et heure pour voir le fichier tel qu'il était à ce moment-là.

Date et heureVignetteDimensionsUtilisateurCommentaire
actuel1 octobre 2020 à 15:04Vignette pour la version du 1 octobre 2020 à 15:04435 × 400 (20 kio)KrishnavedalaText-to-graph aspect ratio renders poorly in thumbnails with text unreadable.
3 juillet 2019 à 03:25Vignette pour la version du 3 juillet 2019 à 03:25512 × 512 (42 kio)Bob Kchange graph "linewidth" to 2
2 juillet 2019 à 15:03Vignette pour la version du 2 juillet 2019 à 15:03512 × 512 (42 kio)Bob KEnlarge image. Add title. Improve rendering of "pi" symbols.
22 août 2017 à 18:23Vignette pour la version du 22 août 2017 à 18:23435 × 400 (20 kio)Krishnavedalacorrections on phase plot
22 août 2017 à 18:11Vignette pour la version du 22 août 2017 à 18:11435 × 400 (20 kio)Krishnavedalanew version using Matplotlib
21 août 2017 à 17:26Vignette pour la version du 21 août 2017 à 17:26512 × 384 (42 kio)Krishnavedalathicker lines and uses unicode text
17 août 2017 à 00:01Vignette pour la version du 17 août 2017 à 00:01576 × 432 (43 kio)KrishnavedalaUse Unicode for Greek symbols
16 août 2017 à 23:58Vignette pour la version du 16 août 2017 à 23:58576 × 432 (43 kio)KrishnavedalaUnicode symbols corrected
16 août 2017 à 23:52Vignette pour la version du 16 août 2017 à 23:52576 × 432 (43 kio)Krishnavedalaregenerate using "gnuplot" backend
16 août 2017 à 23:31Vignette pour la version du 16 août 2017 à 23:31576 × 431 (28 kio)KrishnavedalaUser created page with UploadWizard

Aucune page n’utilise ce fichier.

Usage global du fichier

Les autres wikis suivants utilisent ce fichier :

Métadonnées