diff --git a/.gitignore b/.gitignore
index 859f705..1ac6086 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+signals-and-systems-cheatsheet.pdf
+
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
@@ -19,7 +21,7 @@
# these rules might exclude image files for figures etc.
# *.ps
# *.eps
-# *.pdf
+*.pdf
## Generated if empty string is given at "Please type another file name for output:"
.pdf
diff --git a/.ipynb_checkpoints/signals-and-systems-cheatsheet-checkpoint.ipynb b/.ipynb_checkpoints/signals-and-systems-cheatsheet-checkpoint.ipynb
new file mode 100644
index 0000000..13163a3
--- /dev/null
+++ b/.ipynb_checkpoints/signals-and-systems-cheatsheet-checkpoint.ipynb
@@ -0,0 +1,2659 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "64ead2a4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "from scipy.signal import square\n",
+ "from scipy.special import diric\n",
+ "import matplotlib.colors as colors\n",
+ "import scipy.signal as signal\n",
+ "import sympy.integrals.transforms as transforms\n",
+ "from sympy import *\n",
+ "from sympy.solvers.solvers import solve\n",
+ "from IPython.display import display, Math\n",
+ "from matplotlib.patches import Circle\n",
+ "plt.rcParams.update({\n",
+ " \"text.usetex\" : True,\n",
+ " \"text.latex.preamble\" : r\"\\usepackage{amssymb} \\usepackage{amsmath} \\usepackage{faktor} \\newcommand{\\im}{\\mathrm{j}} \\newcommand{\\e}{\\mathrm{e}}\",\n",
+ " \"font.size\" : 11,\n",
+ "})"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d86015a1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def rect_impulse(t,Th):\n",
+ " x = np.zeros_like(t)\n",
+ " i = np.where((t >= -Th/2) & (t <= Th/2))\n",
+ " x[i] = 1\n",
+ " return x\n",
+ "\n",
+ "def tri_impulse(t,Th):\n",
+ " x = np.zeros_like(t)\n",
+ " i = np.where((t >= -Th/2) & (t <0))\n",
+ " x[i] = 2/Th*t[i]+1\n",
+ " i = np.where((t <= +Th/2) & (t >= 0))\n",
+ " x[i] = -2/Th*t[i]+1\n",
+ " return x\n",
+ "\n",
+ "def triangular_wave(t,T,Th,A):\n",
+ " t = np.mod(t,T)\n",
+ " x = np.zeros_like(t)\n",
+ " i = np.where(t <= Th/2)\n",
+ " x[i] = -2*A/Th*t[i]+A\n",
+ " i = np.where(t >= T-Th/2)\n",
+ " x[i] = 2*A/Th*t[i]+A*(1-2*T/Th)\n",
+ " return x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a803c473",
+ "metadata": {},
+ "source": [
+ "---\n",
+ "header-includes:\n",
+ " - \\usepackage{amssymb}\n",
+ " - \\usepackage{trfsigns}\n",
+ "---"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2e38b436",
+ "metadata": {},
+ "source": [
+ "$\\newcommand{\\e}{\\mathrm{e}}$\n",
+ "$\\newcommand{\\im}{\\mathrm{j}}$\n",
+ "$\\newcommand{\\sinc}{\\mathrm{sinc}}$\n",
+ "### Fourierkoeffizienten Rechteckschwingung\n",
+ "\\begin{gather}\n",
+ "\tX_0=2\\int_0^{\\frac{T_h}{2}}A\\mathrm{d}t \n",
+ "= 2At\\Bigg |_{t=0}^{t=\\frac{T_h}{2}}=A\\cdot T_h\\\\\n",
+ "\tX_\\mu=\\int_{-\\frac{T_h}{2}}^{\\frac{T_h}{2}}A\\e^{-\\im k \\omega_0 t}\\mathrm{d}t=\\frac{A}{\\im k \\omega_0}\\left(\\e^{\\im \\pi \\frac{T_h}{T}}-\\e^{-\\im \\pi \\mu \\frac{T_h}{T}}\\right)\\\\\n",
+ "\t=\\frac{AT}{\\im \\mu 2\\pi }\\left(\\e^{\\im \\pi \\mu \\frac{T_h}{T}}-\\e^{-\\im \\pi \\mu \\frac{T_h}{T}}\\right)\n",
+ "\t=\\frac{AT}{\\mu\\pi}\\sin(\\pi \\mu \\frac{T_h}{T})\\\\\n",
+ "\t=\\frac{AT}{\\mu\\pi}\\frac{T_h}{T_h}\\sin(\\pi \\mu \\frac{T_h}{T})={AT_h}\\frac{\\sin(\\pi \\mu \\frac{T_h}{T})}{\\pi \\mu \\frac{T_h}{T}}=A\\cdot T_h\\mathrm{sinc}(\\pi \\mu \\frac{T_h}{T})\n",
+ "\\end{gather}\n",
+ "### Faltung von $x(t)$ mit $y(t)$\n",
+ "\\begin{gather}\n",
+ "\tx(t)\\ast y(t)=\\begin{cases}\n",
+ "\t\t\\int_{t-T_h}^{-T+\\frac{T_h}{2}}\\frac{A^2}{2}\\mathrm{d}\\tau=\\frac{A^2}{2}\\left(-T+\\frac{T_h}{2}-t+T_h\\right)=-\\frac{A^2}{2}\\left(t+T-3\\frac{T_h}{2}\\right)&,-\\frac{T}{2}\\leq t \\leq -\\frac{T_h}{2}\\\\\n",
+ "\t\t\\int_{-\\frac{T_h}{2}}^{t}\\frac{A^2}{2}\\mathrm{d}\\tau=\\frac{A^2}{2}\\left(t+\\frac{T_h}{2}\\right)&,\\frac{-T_h}{2}\\leq t \\leq \\frac{T_h}{2} \\\\\n",
+ "\t\t\\int_{t-T_h}^{\\frac{T_h}{2}}\\frac{A^2}{2}\\mathrm{d}\\tau=\\frac{A^2}{2}\\left(\\frac{T_h}{2}-t+T_h\\right)=-\\frac{A^2}{2}\\left(t-3\\frac{T_h}{2}\\right)&,\\frac{T_h}{2}\\leq t \\leq \\frac{T}{2}\n",
+ "\t\\end{cases}\n",
+ "\\end{gather}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4199224a",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [],
+ "source": [
+ "#fourier series of square wave, time shifted square wave and convolution between these two\n",
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "t = np.arange(-5,5+1/1000,1/1000)\n",
+ "k = np.arange(-500,501)\n",
+ "kk, tt = np.meshgrid(k,t)\n",
+ "w = np.exp(1j*kk*tt*2*np.pi/T)\n",
+ "\n",
+ "\n",
+ "x = A*(square((t+Th/2)/T*2*np.pi,duty=Th/T)+1)/2\n",
+ "y= A/2*(square((t)/T*2*np.pi,duty=Th/T)+1)/2\n",
+ "z = A*Th*np.sinc(kk*Th/T)*1/2*A*Th*np.sinc(kk*Th/T)*np.exp(-1j*2*np.pi/T*kk*Th/2)*w\n",
+ "z = np.reshape(z, (t.size,k.size))\n",
+ "z = 1/T*np.sum(z,axis=1)\n",
+ "z = np.real(z)\n",
+ "\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T_0$','$-T_0$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T_0$','$+2T_0$'])\n",
+ "ax.set_xlabel('$t$')\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_title(r'$x(t)=\\mathrm{rect}\\left(\\frac{t}{T_h}\\right),\\quad\\quad x(t)=x(t+T_0),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "\n",
+ "k = np.arange(-5,6,1)\n",
+ "X = A*Th*np.sinc(k*Th/T)\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "X_ph = np.angle(X)\n",
+ "i = np.where(k >0,1,0)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i==True)\n",
+ "X_ph[i] = -np.pi\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\left|\\tilde{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\left|\\tilde{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\left|\\tilde{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,X_ph,marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\varphi\\left(\\tilde{X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\varphi\\left(\\tilde{Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\varphi\\left(\\tilde{Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "# gestrichelte Linie zeichnen\n",
+ "\n",
+ "k = np.arange(-5,5+1/1000,1/1000)\n",
+ "X = A*Th*np.sinc(k*Th/T)\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "X_ph = np.angle(X)\n",
+ "i = np.where(k>0,1,10)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_ph[i] *= (-1)*np.sign(k)[i]\n",
+ "\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,X_ph,ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "xticks = np.arange(-5,5+1,1)\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "labels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-5,5)\n",
+ "ax2.set_xlim(-5,5)\n",
+ "ax3.set_xlim(-5,5)\n",
+ "ax4.set_xlim(-5,5)\n",
+ "ax5.set_xlim(-5,5)\n",
+ "ax6.set_xlim(-5,5)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th+A*Th/2,A*Th/2))\n",
+ "ax1.set_yticklabels(['0',r'$\\faktor{AT_h}{2}$',\n",
+ " '$A T_h$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{4}$',\n",
+ " r'$\\faktor{A T_h}{2}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/2+A**2*Th**2/4,A**2*Th**2/4))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{4}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(labels)\n",
+ "ax5.set_yticklabels(labels)\n",
+ "ax6.set_yticklabels(labels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=12,loc='center right')\n",
+ "ax2.legend(fontsize=12,loc='center right')\n",
+ "ax3.legend(fontsize=12,loc='center right')\n",
+ "ax4.legend(fontsize=12,loc='upper right')\n",
+ "ax5.legend(fontsize=12,loc='upper right')\n",
+ "ax6.legend(fontsize=12,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('fourier_series_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2b3797b1",
+ "metadata": {},
+ "source": [
+ "$\\newcommand{\\e}{\\mathrm{e}}$\n",
+ "$\\newcommand{\\im}{\\mathrm{j}}$\n",
+ "$\\newcommand{\\sinc}{\\mathrm{sinc}}$\n",
+ "### Fourierkoeffizienten Dreieckschwingung\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\tX_\\mu = \\int_{-\\frac{T_h}{2}}^{+\\frac{T_h}{2}}x(t)\\e^{-\\im \\mu \\omega t}\\mathrm{d}t=\\int_{-\\frac{T_h}{2}}^0\\left(\\frac{2A}{T_h}t+A\\right)\\e^{-\\im \\mu \\omega t}\\mathrm{d}t+\\int_0^{+\\frac{T_h}{2}}\\left(-\\frac{2A}{T_h}t+A\\right)\\e^{-\\im \\mu \\omega t}\\mathrm{d}t\\\\\n",
+ "\t=\\frac{\\left(\\frac{2A}{T_h}t+A\\right)}{-\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\Bigg|_{t=-\\frac{T_h}{2}}^{0}+\\int_{-\\frac{T_h}{2}}^0\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\mathrm{d}t+\\frac{\\left(-\\frac{2A}{T_h}t+A\\right)}{-\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\Bigg|_{t=0}^{+\\frac{T_h}{2}}-\\int_0^{+\\frac{T_h}{2}}\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\mathrm{d}t\\\\\n",
+ "\t=-\\frac{A}{\\im \\mu \\omega }+\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\mu^2\\omega^2}\\e^{-\\im \\mu \\omega t}\\Bigg |_{t=-\\frac{T_h}{2}}^{t=0}+\\frac{A}{\\im \\mu \\omega}+\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\mu^2\\omega^2}\\e^{-\\im \\mu \\omega t}\\Bigg |_{t=+\\frac{T_h}{2}}^{t=0}\\\\\n",
+ "\t=\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\mu^2\\omega^2}\\left[2-\\e^{\\im \\mu \\omega \\frac{T_h}{2}}-\\e^{-\\im \\mu \\omega \\frac{T_h}{2}}\\right]=\\frac{\\left(\\frac{4A}{T_h}\\right)}{\\mu^2\\omega^2}\\left[1-\\cos(\\mu\\pi\\frac{T_h}{T})\\right]\n",
+ "\\end{gather}\n",
+ "Es gilt (S. 83 in I. Bronshtein, K. Semendyayev, G. Musiol, and H. Mühlig, Handbook of\n",
+ "Mathematics, 6th ed. Springer Berlin, Heidelberg, 2015.):\n",
+ "\\begin{gather}\n",
+ "\t\\sin^2(\\alpha)=\\frac{1}{2}(1-\\cos(2\\alpha))\n",
+ "\\end{gather}\n",
+ "Also:\n",
+ "\\begin{gather}\n",
+ "\t\\frac{\\left(\\frac{4A}{T_h}\\right)}{\\mu^2\\omega^2}\\left[1-\\cos(\\mu\\pi\\frac{T_h}{T})\\right]=\\frac{\\left(\\frac{4AT^2}{T_h}\\right)}{\\mu^24\\pi^2}\\left[1-\\cos(\\mu\\pi\\frac{T_h}{T})\\right]=\\frac{2AT^2}{T_h\\mu^2\\pi^2}\\cdot\\frac{1}{2}\\left[1-\\cos\\left(2\\mu\\pi\\frac{T_h}{2T}\\right)\\right]\\\\\n",
+ "\t=\\frac{2AT^2}{T_h\\mu^2\\pi^2}\\left[\\sin^2\\left(\\mu\\pi\\frac{T_h}{2T}\\right)\\right]=\\frac{T_hA}{2}\\frac{4T^2}{T_h^2\\mu^2\\pi^2}\\left[\\sin^2\\left(\\mu\\pi\\frac{T_h}{2T}\\right)\\right]=\\frac{A\\cdot T_h}{2}\\sinc^2\\left(\\mu\\pi\\frac{T_h}{2T}\\right)\n",
+ "\\end{gather}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "dd807a53",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "k = np.arange(-500,501)\n",
+ " \n",
+ "ax = fig.add_subplot(311)\n",
+ "ax.set_xlabel('$t$')\n",
+ "\n",
+ "x = triangular_wave(t=t,T=T,Th=Th,A=A)\n",
+ "y = triangular_wave(t=t-Th/2,T=T,Th=Th,A=A)/2\n",
+ "\n",
+ "z = A*Th/2*np.sinc(kk*Th/(2*T))**2*1/2*A*Th/2*np.sinc(kk*Th/(2*T))**2*np.exp(-1j*2*np.pi/T*kk*Th/2)*w\n",
+ "z = np.reshape(z, (t.size,k.size))\n",
+ "z = 1/T*np.sum(z,axis=1)\n",
+ "z = np.real(z)\n",
+ "\n",
+ "\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T_0$','$-T_0$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T_0$','$+2T_0$'])\n",
+ "\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_title(r'$x(t)=\\mathrm{tri}\\left(2\\frac{t}{T_h}\\right),\\quad\\quad x(t)=x(t+T_0),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "\n",
+ "k = np.arange(-5,5+1,1)\n",
+ "X = A*Th/2*np.sinc(k*Th/(2*T))**2\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\left|\\tilde{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\left|\\tilde{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\left|\\tilde{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,np.angle(X),marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\varphi\\left(\\tilde{X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\varphi\\left(\\tilde{Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\varphi\\left(\\tilde{Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "k = np.arange(-5,5+1/1000,1/1000)\n",
+ "X = A*Th/2*np.sinc(k*Th/(2*T))**2\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,np.angle(X),ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "xticks = np.arange(-5,5+1,1)\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "labels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-5,5)\n",
+ "ax2.set_xlim(-5,5)\n",
+ "ax3.set_xlim(-5,5)\n",
+ "ax4.set_xlim(-5,5)\n",
+ "ax5.set_xlim(-5,5)\n",
+ "ax6.set_xlim(-5,5)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax1.set_yticklabels(['0',r'$\\faktor{A T_h}{4}$',\n",
+ " r'$\\faktor{A T_h}{2}$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/4+A*Th/8,A*Th/8))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{8}$',\n",
+ " r'$\\faktor{A T_h}{4}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/8+A**2*Th**2/16,A**2*Th**2/16))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{16}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{8}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(labels)\n",
+ "ax5.set_yticklabels(labels)\n",
+ "ax6.set_yticklabels(labels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('fourier_series_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6df56812",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "# time domain\n",
+ "t = np.arange(-5,5+1/1000,1/1000)\n",
+ "x = rect_impulse(t,Th)*A\n",
+ "y = rect_impulse(t-Th/2,Th)*A/2\n",
+ "z = np.zeros_like(t)\n",
+ "i = np.where((-Th/2<=t) & (t < Th/2))\n",
+ "z[i] = A**2/2*(t[i]+Th/2)\n",
+ "i = np.where((Th/2 <= t) & (t < 3*Th/2))\n",
+ "z[i] = A**2/2*(-t[i]+3*Th/2)\n",
+ "\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "# axis settings\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T$','$-T$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T$','$+2T$'])\n",
+ "\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_xlabel('$t$')\n",
+ "ax.set_title(r'$x(t)=\\mathrm{rect}\\left(\\frac{t}{T_h}\\right),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "\n",
+ "omega = np.arange(-5*2*np.pi/T,5*2*np.pi/T+1/1000,1/1000)\n",
+ "X = np.sinc(omega/2*Th/np.pi)*Th*A\n",
+ "Y = np.sinc(omega/2*Th/np.pi)*Th*A/2*np.exp(-1j*omega*Th/2)\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "\n",
+ "# swap pi with -pi for omega > 0 (point reflection)\n",
+ "X_ph = np.angle(X)\n",
+ "i = np.where(omega > 0,1,0)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_ph[i] = -np.pi\n",
+ "\n",
+ "# plot FT magnitude\n",
+ "ax1.plot(omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot FT phase\n",
+ "ax4.plot(omega,X_ph,color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left(\\tilde{Z}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "# axis settings for frequency domain\n",
+ "xticks = np.arange(-5*2*np.pi/T,+5*2*np.pi/T+2*np.pi/T,2*np.pi/T)\n",
+ "xlabels = ['$-5\\omega_0$','','','$-2\\omega_0$','','$0$',\n",
+ " '','$2\\omega_0$','','','$5\\omega_0$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax2.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax3.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax4.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax5.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax6.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "ax1.set_xlabel('$\\omega$')\n",
+ "ax2.set_xlabel('$\\omega$')\n",
+ "ax3.set_xlabel('$\\omega$')\n",
+ "ax4.set_xlabel('$\\omega$')\n",
+ "ax5.set_xlabel('$\\omega$')\n",
+ "ax6.set_xlabel('$\\omega$')\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th+A*Th/2,A*Th/2))\n",
+ "ax1.set_yticklabels(['0',r'$\\faktor{A T_h}{2}$',\n",
+ " r'$A T_h$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{4}$',\n",
+ " r'$\\faktor{A T_h}{2}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/2+A**2*Th**2/4,A**2*Th**2/4))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{4}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('continuous_fouriertrafo_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b4a8bfc2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "\n",
+ "# time domain\n",
+ "t = np.arange(-5,5+1/1000,1/1000)\n",
+ "x = tri_impulse(t,Th)*A\n",
+ "y = tri_impulse(t-Th/2,Th)*A/2\n",
+ "z = np.convolve(x,y)/1000\n",
+ "t2 = np.arange(-5*2,2*(5+1/1000),1/1000)\n",
+ "i = np.where((t2 >= -5) & (t2 <= 5))\n",
+ "z = z[i]\n",
+ "t2 = t2[i]\n",
+ "\n",
+ "# axis settings\n",
+ "ax.set_xlabel('$t$')\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t2,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T$','$-T$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T$','$+2T$'])\n",
+ "\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_title(r'$x(t)=\\mathrm{tri}\\left(2\\frac{t}{T_h}\\right),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "omega = np.arange(-5*2*np.pi/T,5*2*np.pi/T+1/1000,1/1000)\n",
+ "X = A*Th/2*np.sinc(omega/4*Th/np.pi)**2\n",
+ "Y = A*Th/4*np.sinc(omega/4*Th/np.pi)**2*np.exp(-1j*omega*Th/2)\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "\n",
+ "# plot FT magnitude\n",
+ "ax1.plot(omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot FT phase\n",
+ "\n",
+ "ax4.plot(omega,np.angle(X),color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "# axis settings\n",
+ "\n",
+ "xticks = np.arange(-5*2*np.pi/T,+5*2*np.pi/T+2*np.pi/T,2*np.pi/T)\n",
+ "xlabels = ['$-5\\omega_0$','','','$-2\\omega_0$','','$0$',\n",
+ " '','$2\\omega_0$','','','$5\\omega_0$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax2.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax3.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax4.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax5.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax6.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "ax1.set_xlabel('$\\omega$')\n",
+ "ax2.set_xlabel('$\\omega$')\n",
+ "ax3.set_xlabel('$\\omega$')\n",
+ "ax4.set_xlabel('$\\omega$')\n",
+ "ax5.set_xlabel('$\\omega$')\n",
+ "ax6.set_xlabel('$\\omega$')\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax1.set_yticklabels(['0',r'$\\frac{A T_h}{4}$',\n",
+ " r'$\\frac{A T_h}{2}$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/4+A*Th/8,A*Th/8))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{8}$',\n",
+ " r'$\\faktor{A T_h}{4}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/8+A**2*Th**2/16,A**2*Th**2/16))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{16}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{8}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('continuous_fouriertrafo_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "145aac8f",
+ "metadata": {},
+ "source": [
+ "ẞ"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "e1fcf0b0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "# time domain\n",
+ "k = np.arange(-Th/2,Th+Th/4,Th/4)\n",
+ "x = rect_impulse(k,Th)*A\n",
+ "y = rect_impulse(k-Th/2,Th)*A/2\n",
+ "z = np.convolve(x,y)\n",
+ "k2 = np.arange(-Th,2*Th+Th/4,Th/4)\n",
+ "\n",
+ "ax.plot(k,x,label='$x[k]$',\n",
+ " mfc=color1,mec=color1,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-2]$',\n",
+ " mfc=color2,mec=color2,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k2,z,label=r'$z[k]=x[k]\\ast y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls=':',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "#gestrichelte Linien zwischen den Samples\n",
+ "\n",
+ "k = np.arange(-2*T,2*T+1/1000,1/1000)\n",
+ "x = rect_impulse(k,Th)*A\n",
+ "y = rect_impulse(k-Th/2,Th)*A/2\n",
+ "\n",
+ "ax.plot(k,x,ls=':',color=color1)\n",
+ "ax.plot(k,y,ls=':',color=color2)\n",
+ "\n",
+ "\n",
+ "#Abwechselnde Farben der Samples\n",
+ "k = np.arange(7*Th/4,2*T+0.01,3*Th/4)\n",
+ "k = np.append(k,np.arange(-2*T+Th/4,-3*Th/4+Th/4,3*Th/4))\n",
+ "plt.plot(k,np.zeros_like(k),ls='',marker='o',mec=color1,mfc=color1,clip_on=False)\n",
+ "\n",
+ "k = np.arange(9*Th/4,2*T,3*Th/4)\n",
+ "k = np.append(k,np.arange(-2*T+Th/2,-3*Th/4+Th/4,3*Th/4))\n",
+ "plt.plot(k,np.zeros_like(k),ls='',marker='o',mec=color3,mfc=color3,clip_on=False)\n",
+ "\n",
+ "k = np.arange(8*Th/4,2*T,3*Th/4)\n",
+ "k = np.append(k,np.arange(-2*T,-3*Th/4+Th/4,3*Th/4))\n",
+ "plt.plot(k,np.zeros_like(k),ls='',marker='o',mec=color2,mfc=color2,clip_on=False)\n",
+ "#axis settings\n",
+ "ax.set_xlabel('$k$')\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks(np.arange(-2*T,2*T+Th/4,Th/2))\n",
+ "labels = []\n",
+ "for i in np.arange(-2*T,2*T+Th/4,Th/2):\n",
+ " labels += ['$'+str(int(4*i/Th))+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "\n",
+ "ax.set_ylim(0,5*A**2/2)\n",
+ "ax.set_yticks([0,5*A**2/2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$'])\n",
+ "ax.set_title(r'x[k]=$\\mathrm{rect}_5[k-2]$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "#frequency domain\n",
+ "Omega = np.arange(-2*np.pi,2*np.pi+1/10000,1/10000)\n",
+ "X=A*5*diric(Omega,5)\n",
+ "Y=X/2*np.exp(-2j*Omega)\n",
+ "Z=X*Y\n",
+ "\n",
+ "X_ph = np.angle(X)\n",
+ "# swap pi to - pi for 0 <= Omega mod 2pi <= pi (point reflection)\n",
+ "i = np.where(np.mod(Omega,2*np.pi)<=np.pi,1,0)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_ph[i] = -np.pi\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\Omega$')\n",
+ "ax2.set_xlabel('$\\Omega$')\n",
+ "ax3.set_xlabel('$\\Omega$')\n",
+ "ax4.set_xlabel('$\\Omega$')\n",
+ "ax5.set_xlabel('$\\Omega$')\n",
+ "ax6.set_xlabel('$\\Omega$')\n",
+ "\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(Omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(Omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega,X_ph,color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(Omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(Omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "# axis settings\n",
+ "xticks = np.arange(-2*np.pi,2*np.pi+np.pi/2,np.pi)\n",
+ "xlabels = ['$-2\\pi$','$-\\pi$','$0$','$+\\pi$','$+2\\pi$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-np.pi,+np.pi)\n",
+ "ax2.set_xlim(-np.pi,+np.pi)\n",
+ "ax3.set_xlim(-np.pi,+np.pi)\n",
+ "ax4.set_xlim(-np.pi,+np.pi)\n",
+ "ax5.set_xlim(-np.pi,+np.pi)\n",
+ "ax6.set_xlim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,5*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$','$4A$','$5A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,5*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$',r'$2A$',r'$\\faktor{5A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,25*A**2/2+5*A**2/2,5*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$','$5A^2$',r'$\\faktor{15A^2}{2}$','$10A^2$',r'$\\faktor{25A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DTFT_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "eb130459",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "# time domain\n",
+ "k = np.arange(-2*T,2*T+0.0001,Th/6)\n",
+ "x = tri_impulse(k,Th)*A\n",
+ "y = tri_impulse(k-Th/2,Th)*A/2\n",
+ "z = np.convolve(x,y)\n",
+ "k2 = np.arange(-4*T,4*T+0.000001,Th/6)\n",
+ "z = z[np.where(np.abs(k2)<=2*T+0.00000001)]\n",
+ "\n",
+ "\n",
+ "ax.plot(k,x,label='$x[k]$',color=color1,\n",
+ " mfc=color1,mec=color1,ls=':',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-3]$',color=color2,\n",
+ " mfc=color2,mec=color2,ls=':',marker='o',clip_on=False)\n",
+ "ax.plot(k,z,label=r'$z[k]=x[k]\\ast y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls=':',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "#Abwechselnde Farben der Samples\n",
+ "k = np.append(np.arange(7,24+0.0000001,3),np.arange(-1,-24-0.0000001,-3))\n",
+ "plt.plot(k*Th/6,np.zeros_like(k),ls='',marker='o',mec=color1,mfc=color1,clip_on=False)\n",
+ "\n",
+ "k = np.append(np.arange(6,24+0.0000001,3),np.arange(0,-24-0.00001,-3))\n",
+ "plt.plot(k*Th/6,np.zeros_like(k),ls='',marker='o',mec=color2,mfc=color2,clip_on=False)\n",
+ "\n",
+ "k = np.append(np.arange(8,24+0.0000001,3),np.arange(-2,-24-0.0000001,-3))\n",
+ "plt.plot(k*Th/6,np.zeros_like(k),ls='',marker='o',mec=color3,mfc=color3,clip_on=False)\n",
+ "# axis settings\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks(np.arange(-24,24+0.0000001,3)*Th/6)\n",
+ "labels = []\n",
+ "for i in np.arange(-24,24+0.0000001,3,dtype=int):\n",
+ " labels += ['$'+str(i)+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "ax.set_xlabel('$k$')\n",
+ "ax.set_ylim(0,19/18*A**2)\n",
+ "ax.set_yticks([0,19/18*A**2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{19A^2}{18}$'])\n",
+ "ax.set_title(r'$x[k]=\\mathrm{tri}_3[k]$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "Omega = np.arange(-2*np.pi,2*np.pi+1/10000,1/10000)\n",
+ "X = A*diric(Omega,3)**2*3\n",
+ "Y = X/2*np.exp(-3j*Omega)\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\Omega$')\n",
+ "ax2.set_xlabel('$\\Omega$')\n",
+ "ax3.set_xlabel('$\\Omega$')\n",
+ "ax4.set_xlabel('$\\Omega$')\n",
+ "ax5.set_xlabel('$\\Omega$')\n",
+ "ax6.set_xlabel('$\\Omega$')\n",
+ "\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(Omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(Omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega,np.angle(X),color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(Omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(Omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "# axis settings\n",
+ "xticks = np.arange(-2*np.pi,2*np.pi+np.pi/2,np.pi)\n",
+ "xlabels = ['$-2\\pi$','$-\\pi$','$0$','$+\\pi$','$+2\\pi$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-np.pi,+np.pi)\n",
+ "ax2.set_xlim(-np.pi,+np.pi)\n",
+ "ax3.set_xlim(-np.pi,+np.pi)\n",
+ "ax4.set_xlim(-np.pi,+np.pi)\n",
+ "ax5.set_xlim(-np.pi,+np.pi)\n",
+ "ax6.set_xlim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,3*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,3*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,9*A**2/2+3*A**2/2,3*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{3A^2}{2}$','$3A^2$',r'$\\faktor{9A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DTFT_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e54d900b",
+ "metadata": {},
+ "source": [
+ "---\n",
+ "header-includes:\n",
+ " - \\usepackage{amssymb}\n",
+ " - \\usepackage{trfsigns}\n",
+ "---\n",
+ "DTFT eines Dreieickes:\n",
+ "Faltung von $\\mathrm{rect}_[k]$ mit sich selbst ergibt ein Dreieck der Länge\n",
+ "2N+1$ mit Maximum bei N-1.\n",
+ "\n",
+ "DTFT durch Multiplikation der DTFTs des Rechtecksignals:\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\t\\mathrm{rect}_N[k]\\ast\\mathrm{rect}_N[k]\\quad\\fourier\\quad\\e^{-\\im\\Omega(N-1)}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ "\\end{gather}\n",
+ "\n",
+ "Mittelpunkt des Dreiecks soll bei 0 liegen, also Verschiebung um $N-1$ nach \n",
+ "links.\n",
+ "\n",
+ "Durch Faltung steigt das Dreieck jeweils um 1 bis zu einem Maximum \n",
+ "bei $N-1$ von $N$.\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\tN\\cdot \\mathrm{tri}_{N}[k]=\\e^{-\\im\\Omega(N-1)}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\\cdot\\e^{+j\\Omega(N-1)}=\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ "\\end{gather}\n",
+ "\n",
+ "N muss noch auf die andere Seite gebracht werden.\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\t\\mathrm{tri}_{N}[k]\\quad\\fourier\\quad\\frac{1}{N}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ "\\end{gather}\n",
+ "\n",
+ "Dies ist eine Korrespondenz für einen Dreiecksimpuls der Länge $2N+1$ (bzw. $2N-1$, wenn die Nullen an den Rändern nicht mitgezählt werden) mit der\n",
+ "Spitze bei $k=0$.\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\t\\mathrm{tri}_N[k]=\n",
+ "\t\\begin{cases}\n",
+ "\t\t1-\\frac{k}{N}, &0 \\leq k \\leq N-1,\\\\\n",
+ "\t\t1+\\frac{k}{N}, &-N+1\\leq k < 0,\\\\\n",
+ "\t\t0, &\\text{sonst}.\n",
+ "\t\\end{cases}\n",
+ "\\end{gather}\n",
+ "\n",
+ "\n",
+ "\n",
+ "\\begin{gather}\n",
+ " \\lim\\limits_{\\Omega\\rightarrow0}\\frac{1}{N}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ " =\\lim\\limits_{\\Omega\\rightarrow0}\\frac{1}{N}\\cdot\\frac{2\\sin\\left(N\\frac{\\Omega}{2}\\right)\\cos\\left(N\\frac{\\Omega}{2}\\right)\\frac{N}{2}}{2\\sin\\left(\\frac{\\Omega}{2}\\right)\\cos\\left(\\frac{\\Omega}{2}\\right)\\frac{1}{2}}\\\\\n",
+ "\t=\\lim\\limits_{\\Omega\\rightarrow0}\n",
+ "\t\\frac{\n",
+ "\t\t\\cos^2\\left(N\\frac{\\Omega}{2}\\right)\\frac{N}{2}-\\sin^2\\left(N\\frac{\\Omega}{2}\\right)\\frac{N}{2}\n",
+ "\t}\n",
+ "\t{\n",
+ "\t\t\\cos^2\\left(\\frac{\\Omega}{2}\\right)\\frac{1}{2}-\\sin^2\\left(\\frac{\\Omega}{2}\\right)\\frac{1}{2}\n",
+ "\t}\n",
+ "\t=N\n",
+ "\\end{gather}\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b5cecf4d",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "# time domain\n",
+ "\n",
+ "k = np.arange(0,8,1/1000)\n",
+ "x = A*(square((k+2)/8*2*np.pi,0.5)+1)/2\n",
+ "y = A/2*(square(k/8*2*np.pi,0.5)+1)/2\n",
+ "\n",
+ "ax.plot(k,x,ls='--',color=color1,clip_on=False)\n",
+ "ax.plot(k,y,ls='--',color=color2,clip_on=False)\n",
+ "\n",
+ "k = np.arange(-16,0,1/1000)\n",
+ "x = A*(square((k+2)/8*2*np.pi,0.5)+1)/2\n",
+ "y = A/2*(square(k/8*2*np.pi,0.5)+1)/2\n",
+ "\n",
+ "ax.plot(k,x,ls=':',color=color1,clip_on=False)\n",
+ "ax.plot(k,y,ls=':',color=color2,clip_on=False)\n",
+ "\n",
+ "k = np.arange(8,16+1/1000,1/1000)\n",
+ "x = A*(square((k+2)/8*2*np.pi,0.5)+1)/2\n",
+ "y = A/2*(square(k/8*2*np.pi,0.5)+1)/2\n",
+ "\n",
+ "ax.plot(k,x,ls=':',color=color1,clip_on=False)\n",
+ "ax.plot(k,y,ls=':',color=color2,clip_on=False)\n",
+ "\n",
+ "k = np.arange(0,8,dtype=float)\n",
+ "x = np.zeros_like(k)\n",
+ "y = np.zeros_like(k)\n",
+ "\n",
+ "np.put(x,[0,1,2,6,7],A)\n",
+ "#np.put(x,[3,9],A/2)\n",
+ "np.put(y,[0,1,2,3,4],A/2)\n",
+ "#np.put(y,[0,6],A/4)\n",
+ "z = np.real(np.fft.ifft(np.fft.fft(x)*np.fft.fft(y)))\n",
+ "\n",
+ "\n",
+ "#plot period 2, 3 (first element)\n",
+ "k2 = np.append(np.append(k-16,k-8),k[0])\n",
+ "x2 = np.append(np.append(x,x),x[0])\n",
+ "y2 = np.append(np.append(y,y),y[0])\n",
+ "z2 = np.append(np.append(z,z),z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls='',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls='',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "#plot period -2 and -1\n",
+ "\n",
+ "k2 = np.append(k[k.size-1],np.append(k+8,k[0]+16))\n",
+ "x2 = np.append(x[x.size-1],np.append(x,x[0]))\n",
+ "y2 = np.append(y[y.size-1],np.append(y,y[0]))\n",
+ "z2 = np.append(z[z.size-1],np.append(z,z[0]))\n",
+ "\n",
+ "ax.plot(k2,x2,ls='',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls='',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "#plot period 1\n",
+ "ax.plot(k,x,label='$x[k]$',color=color1,\n",
+ " mfc=color1,mec=color1,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-2]$',color=color2,\n",
+ " mfc=color2,mec=color2,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k,z,label=r'$z[k]=x[k]\\circledast_{8} y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls='--',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "# axis settings\n",
+ "\n",
+ "ax.set_xlabel('$k$')\n",
+ "ax.set_xlim(-16,16)\n",
+ "ax.set_xticks(np.arange(-16,16+2,2))\n",
+ "\n",
+ "labels = []\n",
+ "for i in np.arange(-16,16+2,2):\n",
+ " labels += ['$'+str(i)+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "\n",
+ "ax.set_ylim(0,5*A**2/2)\n",
+ "ax.set_yticks([0,5*A**2/2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$'])\n",
+ "ax.set_title(r'$x[k]=\\mathrm{rect}_5[(k-2) \\bmod 8]$')\n",
+ "ax.grid(True)\n",
+ "##########################################\n",
+ "# frequency domain\n",
+ "X = np.fft.fft(x)\n",
+ "Y = np.fft.fft(y)\n",
+ "Z = X*Y\n",
+ "\n",
+ "X_ph = np.angle(X)\n",
+ "X_ph[2] = -np.pi\n",
+ "X_ph[3] = -np.pi\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "##########################################\n",
+ "# plot DTFT magnitude/phase for -2pi <= Omega <= 0\n",
+ "Omega = np.arange(0,2*np.pi+1/1000,1/1000)\n",
+ "X_dtft = A*diric(Omega,5)*5\n",
+ "Y_dtft = X_dtft/2*np.exp(-2j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "X_dtft_ph = np.angle(X_dtft)\n",
+ "# exchange pi to -pi for point reflection (DTFT phase)\n",
+ "i = np.where(Omega <= np.pi,1,0)\n",
+ "j = np.where(X_dtft_ph == np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_dtft_ph[i] = -np.pi\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega*4/np.pi,np.abs(X_dtft),ls='--',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*4/np.pi,np.abs(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*4/np.pi,np.abs(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega*4/np.pi,X_dtft_ph,ls='--',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*4/np.pi,np.angle(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*4/np.pi,np.angle(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DTFT magnitude/phase -2pi <= Omega <= 0\n",
+ "Omega = np.arange(-2*np.pi,1/1000,1/1000)\n",
+ "\n",
+ "X_dtft = A*diric(Omega,5)*5\n",
+ "Y_dtft = X_dtft/2*np.exp(-2j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "X_dtft_ph = np.angle(X_dtft)\n",
+ "# exchange pi to -pi for point reflection (DTFT phase)\n",
+ "i = np.where(Omega <= -np.pi,1,0)\n",
+ "j = np.where(X_dtft_ph == np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_dtft_ph[i] = -np.pi\n",
+ "\n",
+ "ax1.plot(Omega*4/np.pi,np.abs(X_dtft),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*4/np.pi,np.abs(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*4/np.pi,np.abs(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(Omega*4/np.pi,X_dtft_ph,ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*4/np.pi,np.angle(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*4/np.pi,np.angle(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "#plot DFT period 1\n",
+ "ax1.plot(k,np.abs(X),ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\left|{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\left|{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\left|{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,X_ph,ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "##########################################\n",
+ "# plot DFT magnitude/phase period -1,2 (first element)\n",
+ "mu = np.append(k-8,k[0]+8)\n",
+ "X2 = np.append(X,X[0])\n",
+ "Y2 = np.append(Y,Y[0])\n",
+ "Z2 = np.append(Z,Z[0])\n",
+ "X2_ph = np.append(X_ph,X_ph[0])\n",
+ "\n",
+ "ax1.plot(mu,np.abs(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax2.plot(mu,np.abs(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax3.plot(mu,np.abs(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "ax4.plot(mu,X2_ph,ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax5.plot(mu,np.angle(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax6.plot(mu,np.angle(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "\n",
+ "#####################################################################\n",
+ "#axis settings\n",
+ "\n",
+ "xticks = np.arange(-8,8+1,4)\n",
+ "xlabels = ['$-8$','$-4$','$0$','$+4$','$+8$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-k.size,k.size)\n",
+ "ax2.set_xlim(-k.size,k.size)\n",
+ "ax3.set_xlim(-k.size,k.size)\n",
+ "ax4.set_xlim(-k.size,k.size)\n",
+ "ax5.set_xlim(-k.size,k.size)\n",
+ "ax6.set_xlim(-k.size,k.size)\n",
+ "\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,5*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$','$4A$','$5A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,5*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$',r'$2A$',r'$\\faktor{5A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,25*A**2/2+5*A**2/2,5*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$','$5A^2$',r'$\\faktor{15A^2}{2}$','$10A^2$',r'$\\faktor{25A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DFT_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ca43b7f0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(11,9))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "\n",
+ "# time domain\n",
+ "k = np.arange(0,12,dtype=float)\n",
+ "x = np.zeros_like(k)\n",
+ "y = np.zeros_like(k)\n",
+ "\n",
+ "np.put(x,0,A)\n",
+ "np.put(x,1,2*A/3)\n",
+ "np.put(x,2,A/3)\n",
+ "np.put(x,11,2*A/3)\n",
+ "np.put(x,10,A/3)\n",
+ "\n",
+ "\n",
+ "np.put(y,1,A/6)\n",
+ "np.put(y,2,A/3)\n",
+ "np.put(y,3,A/2)\n",
+ "np.put(y,4,A/3)\n",
+ "np.put(y,5,A/6)\n",
+ "\n",
+ "z = np.real(np.fft.ifft(np.fft.fft(x)*np.fft.fft(y)))\n",
+ "\n",
+ "#plot dashed line period 1\n",
+ "k2 = np.append(k,k[0]+12)\n",
+ "x2 = np.append(x,x[0])\n",
+ "y2 = np.append(y,y[0])\n",
+ "z2 = np.append(z,z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls='--',color=color1,\n",
+ " marker='o',mfc=color1,mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls='--',color=color3,\n",
+ " marker='o',mfc=color2,mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls='--',color=color3,\n",
+ " marker='o',mfc=color3,mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot period 2, 3 (first element)\n",
+ "k2 = np.append(np.append(k-24,k-12),k[0])\n",
+ "x2 = np.append(np.append(x,x),x[0])\n",
+ "y2 = np.append(np.append(y,y),y[0])\n",
+ "z2 = np.append(np.append(z,z),z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls=':',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls=':',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "#plot period -2 and -1\n",
+ "\n",
+ "k2 = np.append(k+12,k[0]+24)\n",
+ "x2 = np.append(x,x[0])\n",
+ "y2 = np.append(y,y[0])\n",
+ "z2 = np.append(z,z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls=':',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls=':',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "#plot period 1\n",
+ "ax.plot(k,x,label='$x[k]$',color=color1,\n",
+ " mfc=color1,mec=color1,ls='--',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-3]$',color=color2,\n",
+ " mfc=color2,mec=color2,ls='--',marker='o',clip_on=False)\n",
+ "ax.plot(k,z,label=r'$z[k]=x[k]\\circledast_{12} y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls='--',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "# axis settings\n",
+ "ax.set_xlim(-24,24)\n",
+ "ax.set_xticks(np.arange(-24,24+3,3))\n",
+ "ax.set_xlabel('$k$')\n",
+ "labels = []\n",
+ "for i in np.arange(-24,24+3,3):\n",
+ " labels += ['$'+str(i)+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "\n",
+ "ax.set_ylim(0,19/18*A**2)\n",
+ "ax.set_yticks([0,A/2,A,19/18*A**2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{19A^2}{18}$'])\n",
+ "ax.set_yticks([0,19/18*A**2])\n",
+ "ax.set_title(r'$x[k]=\\mathrm{tri}_3[k\\bmod 12]$')\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "X = np.fft.fft(x)\n",
+ "Y = np.fft.fft(y)\n",
+ "Z = X*Y\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "#plot DFT magnitude period 1\n",
+ "ax1.plot(k,np.abs(X),ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\left|{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\left|{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\left|{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DFT phase period 1\n",
+ "ax4.plot(k,np.angle(X),ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "mu = np.append(k-12,k[0]+12)\n",
+ "X2 = np.append(X,X[0])\n",
+ "Y2 = np.append(Y,Y[0])\n",
+ "Z2 = np.append(Z,Z[0])\n",
+ "\n",
+ "\"\"\"#plot DFT magnitude period -1, 2 (first element)\n",
+ "ax1.plot(mu,np.abs(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax2.plot(mu,np.abs(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax3.plot(mu,np.abs(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "#plot DFT phase period -1, 2 (first element)\n",
+ "ax4.plot(mu,np.angle(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax5.plot(mu,np.angle(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax6.plot(mu,np.angle(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\"\"\"\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "#plot DTFT magnitude/phase 0 <= Omega <= 2 pi\n",
+ "Omega = np.arange(0,2*np.pi+1/1000,1/1000)\n",
+ "\n",
+ "X_dtft = A*diric(Omega,3)**2*3\n",
+ "Y_dtft = X_dtft/2*np.exp(-3j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega*6/np.pi,np.abs(X_dtft),ls='--',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*6/np.pi,np.abs(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*6/np.pi,np.abs(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega*6/np.pi,np.angle(X_dtft),ls='--',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*6/np.pi,np.angle(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*6/np.pi,np.angle(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DTFT magnitude/phase -2pi <= Omega <= 0\n",
+ "Omega = np.arange(-2*np.pi,1/1000,1/1000)\n",
+ "\n",
+ "X_dtft = A*diric(Omega,3)**2*3\n",
+ "Y_dtft = X_dtft/2*np.exp(-3j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "\n",
+ "ax1.plot(Omega*6/np.pi,np.abs(X_dtft),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*6/np.pi,np.abs(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*6/np.pi,np.abs(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(Omega*6/np.pi,np.angle(X_dtft),ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*6/np.pi,np.angle(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*6/np.pi,np.angle(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DFT magnitude period -1, 2 (first element)\n",
+ "ax1.plot(mu,np.abs(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax2.plot(mu,np.abs(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax3.plot(mu,np.abs(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "#plot DFT phase period -1, 2 (first element)\n",
+ "ax4.plot(mu,np.angle(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax5.plot(mu,np.angle(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax6.plot(mu,np.angle(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "# axis settings\n",
+ "xticks = np.arange(-12,12+1,4)\n",
+ "xlabels = ['$-12$','$-8$','$-4$','$0$','$+4$','$+8$','$+12$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-k.size,k.size)\n",
+ "ax2.set_xlim(-k.size,k.size)\n",
+ "ax3.set_xlim(-k.size,k.size)\n",
+ "ax4.set_xlim(-k.size,k.size)\n",
+ "ax5.set_xlim(-k.size,k.size)\n",
+ "ax6.set_xlim(-k.size,k.size)\n",
+ "\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,3*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,3*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,9*A**2/2+3*A**2/2,3*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{3A^2}{2}$','$3A^2$',r'$\\faktor{9A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DFT_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b798e8bf",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sigma_0 = Symbol('\\sigma_0',positive=True)\n",
+ "s = Symbol('s')\n",
+ "t = Symbol('t')\n",
+ "A = Symbol('A')\n",
+ "omega = Symbol('\\omega')\n",
+ "omega_0 = Symbol('\\omega_0',positive=True)\n",
+ "F = A/(s+sigma_0)\n",
+ "f = transforms.inverse_laplace_transform(F,s,t)\n",
+ "display(Math(latex(f)))\n",
+ "F = A*(s-sigma_0)/(s+sigma_0)\n",
+ "F = apart(F,s)\n",
+ "f = transforms.inverse_laplace_transform(F,s,t)\n",
+ "display(Math(latex(f)))\n",
+ "F = (s+sigma_0/4)/(s-(-sigma_0/4+I*omega_0))/(s-(-sigma_0/4-I*omega_0))\n",
+ "F = apart(F,s)\n",
+ "f = transforms.inverse_laplace_transform(F,s,t)\n",
+ "display(Math(latex(f)))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "27bc8fad",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [],
+ "source": [
+ "fig, ((ax1,ax2),(ax3,ax4),(ax5,ax6)) = plt.subplots(ncols=2,nrows=3,gridspec_kw=dict(width_ratios=[1,2.25]),figsize=(11,9))\n",
+ "\n",
+ "################################################################################\n",
+ "# zeros, poles, gains\n",
+ "\n",
+ "omega_0 = 1\n",
+ "sigma_0 = 1\n",
+ "A=1\n",
+ "s_infty0=-sigma_0+0j*omega_0\n",
+ "s_zero0=sigma_0+0j*omega_0\n",
+ "s_zero1=-sigma_0/4\n",
+ "s_infty1=-sigma_0/4+1j*omega_0\n",
+ "s_infty2=-sigma_0/4-1j*omega_0\n",
+ "s = np.arange(np.real(s_infty0),2+1/1000,1/1000)\n",
+ "s2 = np.arange(np.real(s_infty1),2+1/1000,1/1000)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# s-plane\n",
+ "\n",
+ "ax1.fill_between(s,\n",
+ " np.zeros_like(s)-2,\n",
+ " np.zeros_like(s)+2,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{s\\}$',\n",
+ " alpha=0.5,\n",
+ " )\n",
+ "ax1.set_xlabel(r'$\\mathrm{Re}\\{s\\}$')\n",
+ "ax1.set_ylabel(r'$\\mathrm{Im}\\{s\\}$')\n",
+ "ax1.scatter(np.real(s_infty0),np.imag(s_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "ax1.set_xlim(-2*sigma_0,2*sigma_0)\n",
+ "ax1.set_ylim(-2*omega_0,2*omega_0)\n",
+ "ax1.set_xticks(np.arange(-2,2+1,1))\n",
+ "ax1.set_yticks(np.arange(-2,2+1,1))\n",
+ "ax1.set_xticklabels([r'$-2\\sigma_0$',r'$-\\sigma_0$','$0$',r'$+\\sigma_0$',r'$+2\\sigma_0$'])\n",
+ "ax1.set_yticklabels([r'$-2\\omega_0$',r'$-\\omega_0$',r'$0$',r'$+\\omega_0$',r'$+2\\omega_0$'])\n",
+ "ax1.text(1,-1.5,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax1.grid(True)\n",
+ "ax1.annotate(r'$s_{\\infty,0}$',\n",
+ " (np.real(s_infty0),np.imag(s_infty0)),\n",
+ " (np.real(s_infty0),np.imag(s_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax1.set_box_aspect(1)\n",
+ "ax1.legend(edgecolor='black')\n",
+ "ax1.set_title(r'$H(s)=A\\frac{1}{s+\\sigma_0}$',pad=10)\n",
+ "\n",
+ "# time-domain\n",
+ "\n",
+ "system = signal.lti([],[s_infty0],A)\n",
+ "t = np.arange(0,7*np.log(2)/sigma_0,1/1000)\n",
+ "t, impulse = signal.lti.impulse(system,T=t)\n",
+ "ax2.plot(t,impulse,clip_on=False)\n",
+ "ax2.set_ylim(0,A)\n",
+ "ax2.set_xlim(1,-np.log(2**7)/np.real(s_infty0))\n",
+ "ax2.set_yticks([0,A/8,A/4,A/2,A])\n",
+ "ax2.set_yticklabels(['$0$',r'$\\faktor{A}{8}$',r'$\\faktor{A}{4}$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax2.set_xticks(np.arange(0,-np.log(2**8)/np.real(s_infty0),-np.log(2)/np.real(s_infty0)))\n",
+ "xticklabels=['$0$',r'$\\frac{\\ln(2)}{\\sigma_0}$']\n",
+ "for i in range(2,8):\n",
+ " xticklabels += [r'$\\frac{%d\\ln(2)}{\\sigma_0}$'%(i)]\n",
+ "ax2.set_xticklabels(xticklabels)\n",
+ "ax2.grid(True)\n",
+ "ax2.set_title(r'$h(t)=A\\mathrm{e}^{-\\sigma_0t}\\epsilon(t)$',pad=10)\n",
+ "ax2.set_xlabel('$t$')\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "ax3.fill_between(s,\n",
+ " np.zeros_like(s)-2,\n",
+ " np.zeros_like(s)+2,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{s\\}$',\n",
+ " alpha=0.5,\n",
+ " )\n",
+ "ax3.set_xlabel(r'$\\mathrm{Re}\\{s\\}$')\n",
+ "ax3.set_ylabel(r'$\\mathrm{Im}\\{s\\}$')\n",
+ "ax3.scatter(np.real(s_infty0),np.imag(s_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "\n",
+ "ax3.scatter(np.real(s_zero0),np.imag(s_zero0),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc='none'\n",
+ " )\n",
+ "ax3.set_xlim(-2*sigma_0,2*sigma_0)\n",
+ "ax3.set_ylim(-2*omega_0,2*omega_0)\n",
+ "ax3.set_xticks(np.arange(-2,2+1,1))\n",
+ "ax3.set_yticks(np.arange(-2,2+1,1))\n",
+ "ax3.set_xticklabels([r'$-2\\sigma_0$',r'$-\\sigma_0$','$0$',r'$+\\sigma_0$',r'$+2\\sigma_0$'])\n",
+ "ax3.set_yticklabels([r'$-2\\omega_0$',r'$-\\omega_0$',r'$0$',r'$+\\omega_0$',r'$+2\\omega_0$'])\n",
+ "ax3.text(1,-1.5,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='round',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax3.grid(True)\n",
+ "ax3.annotate(r'$s_{\\infty,0}$',\n",
+ " (np.real(s_infty0),np.imag(s_infty0)),\n",
+ " (np.real(s_infty0),np.imag(s_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "\n",
+ "ax3.annotate(r'$s_{0,0}$',\n",
+ " (np.real(s_zero0),np.imag(s_zero0)),\n",
+ " (np.real(s_zero0),np.imag(s_zero0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax3.set_box_aspect(1)\n",
+ "ax3.legend(edgecolor='black')\n",
+ "\n",
+ "ax3.set_title(r'$H(s)=A\\frac{s-\\sigma_0}{s+\\sigma_0}$',pad=10)\n",
+ "\n",
+ "# time-domain\n",
+ "\n",
+ "system = signal.lti([s_zero0],[s_infty0],A)\n",
+ "t, impulse = signal.lti.impulse(system,T=t)\n",
+ "ax4.plot(t,impulse,clip_on=False)\n",
+ "ax4.annotate(text='',xy=(0,0),xytext=(0,A),\n",
+ " arrowprops=dict(arrowstyle='<-',\n",
+ " connectionstyle='arc3',\n",
+ " shrinkA=0,shrinkB=0,\n",
+ " ec='C0',fc='C0',\n",
+ " lw=1.5,\n",
+ " clip_on=False))\n",
+ "ax4.set_yticks([-2*A,-A,-A/2,-A/4,0,A])\n",
+ "ax4.set_yticklabels(['$-2A\\sigma_0$','$-A\\sigma_0$',r'$-\\faktor{A\\sigma_0}{2}$',r'$-\\faktor{A\\sigma_0}{4}$','$0$','$A$'])\n",
+ "ax4.set_ylim(-2*A*sigma_0,1)\n",
+ "ax4.set_xlim(1,-np.log(2**7)/np.real(s_infty0))\n",
+ "ax4.set_xticks(np.arange(0,-np.log(2**8)/np.real(s_infty0),-np.log(2)/np.real(s_infty0)))\n",
+ "ax4.set_xticklabels(xticklabels)\n",
+ "ax4.grid(True)\n",
+ "ax4.set_title(r'$h(t)=A\\delta(t)-2A\\sigma_0\\e^{-\\sigma_0t}\\epsilon(t)$',pad=10)\n",
+ "ax4.set_xlabel('$t$')\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# s-plane\n",
+ "\n",
+ "ax5.fill_between(s2,\n",
+ " np.zeros_like(s2)-2,\n",
+ " np.zeros_like(s2)+2,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{s\\}$',\n",
+ " alpha=0.5,\n",
+ " )\n",
+ "ax5.set_xlabel(r'$\\mathrm{Re}\\{s\\}$')\n",
+ "ax5.set_ylabel(r'$\\mathrm{Im}\\{s\\}$')\n",
+ "ax5.scatter(np.real(s_infty1),np.imag(s_infty1),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "\n",
+ "ax5.scatter(np.real(s_infty2),np.imag(s_infty2),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "ax5.scatter(np.real(s_zero1),np.imag(s_zero1),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc='none'\n",
+ " )\n",
+ "ax5.set_xlim(-2*sigma_0,2*sigma_0)\n",
+ "ax5.set_ylim(-2*omega_0,2*omega_0)\n",
+ "ax5.set_xticks(np.arange(-2,2+1,1))\n",
+ "ax5.set_yticks(np.arange(-2,2+1,1))\n",
+ "ax5.set_xticklabels([r'$-2\\sigma_0$',r'$-\\sigma_0$','$0$',r'$+\\sigma_0$',r'$+2\\sigma_0$'])\n",
+ "ax5.set_yticklabels([r'$-2\\omega_0$',r'$-\\omega_0$',r'$0$',r'$+\\omega_0$',r'$+2\\omega_0$'])\n",
+ "ax5.text(1,-1.5,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='round',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax5.grid(True)\n",
+ "ax5.annotate(r'$s_{\\infty,1}$',\n",
+ " (np.real(s_infty1),np.imag(s_infty1)),\n",
+ " (np.real(s_infty1),np.imag(s_infty1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax5.annotate(r'$s_{\\infty,2}$',\n",
+ " (np.real(s_infty2),np.imag(s_infty2)),\n",
+ " (np.real(s_infty2),np.imag(s_infty2)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax5.annotate(r'$s_{0,1}$',\n",
+ " (np.real(s_zero1),np.imag(s_zero1)),\n",
+ " (np.real(s_zero1),np.imag(s_zero1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax5.set_box_aspect(1)\n",
+ "ax5.legend(edgecolor='black')\n",
+ "ax5.set_title(r'$H(s)=A\\frac{s+\\faktor{\\sigma_0}{4}}{(s-(-\\faktor{\\sigma_0}{4}+\\im\\omega_0))(s-(-\\faktor{\\sigma_0}{4}-\\im\\omega_0))}$',pad=10)\n",
+ "\n",
+ "# time-domain\n",
+ "\n",
+ "system = signal.lti([s_zero1],[s_infty1,s_infty2],A)\n",
+ "t = np.arange(0,28*np.log(2)/sigma_0+1/1000,1/1000)\n",
+ "t, impulse = signal.lti.impulse(system,T=t)\n",
+ "ax6.plot(t,impulse,clip_on=False)\n",
+ "ax6.set_yticks([-A,-A/2,-A/4,0,A/4,A/2,A])\n",
+ "ax6.set_yticklabels(['$-A$',r'$-\\faktor{A}{2}$',r'$-\\faktor{A}{4}$','$0$',r'$+\\faktor{A}{4}$',r'$+\\faktor{A}{2}$','$+A$'])\n",
+ "ax6.set_ylim(-A,A)\n",
+ "ax6.set_xticks(np.arange(0,28*np.log(2)/sigma_0+4*np.log(2)/sigma_0,4*np.log(2)/sigma_0))\n",
+ "xticklabels = [r'$0$']\n",
+ "for i in range(4,28+4,4):\n",
+ " xticklabels += [r'$\\frac{%d\\ln(2)}{\\sigma_0}$'%(i)]\n",
+ "ax6.set_xticklabels(xticklabels)\n",
+ "ax6.set_xlim(0,28*np.log(2)/sigma_0)\n",
+ "ax6.grid(True)\n",
+ "ax6.set_title(r'$h(t)=\\e^{-\\frac{\\sigma_0}{4}t}\\cos\\left(\\omega t\\right)\\epsilon(t)$',pad=20)\n",
+ "ax6.set_xlabel('$t$')\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('laplace.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "63c3d5e7",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "z = Symbol('z')\n",
+ "r = Symbol('r')\n",
+ "a = Symbol('a')\n",
+ "b = Symbol('b')\n",
+ "phi = Symbol(r'\\varphi')\n",
+ "A = Symbol('A')\n",
+ "Omega_0 = Symbol('Omega_0')\n",
+ "F = (z-2)/(z-Rational(1,2))/z\n",
+ "apart(F,z)*z"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "db252f84",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "fig, ((ax1,ax2),(ax3,ax4),(ax5,ax6)) = plt.subplots(ncols=2,nrows=3,gridspec_kw=dict(width_ratios=[1,2.5]),figsize=(11,9))\n",
+ "\n",
+ "################################################################################\n",
+ "# poles, zeros, gain\n",
+ "A = 1\n",
+ "r = 1/2\n",
+ "Omega_0 = 4*np.log(2)/sigma_0\n",
+ "z_infty0 = r\n",
+ "z_zero0 = 0\n",
+ "#z_zero1 = r+sigma_0\n",
+ "z_zero1 = 1/r\n",
+ "z_zero2 = r*np.cos(Omega_0)\n",
+ "z_infty1 = r*np.exp(1j*Omega_0)\n",
+ "z_infty2 = r*np.exp(-1j*Omega_0)\n",
+ "z = np.arange(-3,3+1/1000,1/1000)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "\n",
+ "ax1.fill_between(z,\n",
+ " np.zeros_like(z)-1.5,\n",
+ " np.zeros_like(z)+1.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax1.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax1.add_patch(circle)\n",
+ "ax1.set_box_aspect(1)\n",
+ "\n",
+ "ax1.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax1.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax1.scatter(np.real(z_infty0),np.imag(z_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax1.annotate(r'$z_{\\infty,0}$',\n",
+ " (np.real(z_infty0),np.imag(z_infty0)),\n",
+ " (np.real(z_infty0),np.imag(z_infty0)-0.25),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "\n",
+ "ax1.scatter(np.real(z_zero0),np.imag(z_zero0),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = 'white',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax1.annotate(r'$z_{0,0}$',\n",
+ " (np.real(z_zero0),np.imag(z_zero0)),\n",
+ " (np.real(z_zero0),np.imag(z_zero0)-0.25),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "ax1.text(0,-0.75,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax1.set_xticks(np.arange(-1,2,1))\n",
+ "ax1.set_yticks(np.arange(-1,2,1))\n",
+ "ax1.set_xlim(-1,1)\n",
+ "ax1.set_ylim(-1,1)\n",
+ "ax1.legend(loc='upper right')\n",
+ "ax1.set_title(r'$H(z)=A\\frac{z}{z-\\faktor{1}{2}}$',pad=20)\n",
+ "ax1.grid(True)\n",
+ "ax1.set_axisbelow(True)\n",
+ "\n",
+ "system = signal.dlti([z_zero0],[z_infty0],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax2.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "impulse2 = z_infty0**k\n",
+ "ax2.plot(k,impulse2,ls=':',color='C0',clip_on=False)\n",
+ "\n",
+ "\n",
+ "ax2.set_xticks(np.arange(0,8))\n",
+ "ax2.set_yticks([0,A/8,A/4,A/2,A])\n",
+ "ax2.set_yticklabels(['$0$',r'$\\faktor{A}{8}$',r'$\\faktor{A}{4}$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "\n",
+ "ax2.set_xlim(0,7)\n",
+ "ax2.set_ylim(0,A)\n",
+ "\n",
+ "ax2.set_xlabel('$k$')\n",
+ "ax2.set_title(r'$h[k]=A\\left(\\frac{1}{2}\\right)^k\\epsilon[k]$',pad=20)\n",
+ "ax2.grid(True)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# z-plane\n",
+ "ax3.fill_between(z,\n",
+ " np.zeros_like(z)-2.5,\n",
+ " np.zeros_like(z)+2.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "ax3.set_box_aspect(1)\n",
+ "\n",
+ "ax3.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax3.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax3.scatter(np.real(z_infty0),np.imag(z_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{\\infty,0}$',\n",
+ " (np.real(z_infty0),np.imag(z_infty0)),\n",
+ " (np.real(z_infty0),np.imag(z_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'right',\n",
+ " \n",
+ " )\n",
+ "\n",
+ "ax3.scatter(np.real(z_zero1),np.imag(z_zero1),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " clip_on=False,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{0,1}$',\n",
+ " (np.real(z_zero1),np.imag(z_zero1)),\n",
+ " (np.real(z_zero1),np.imag(z_zero1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "ax3.text(0,-0.75*2,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax3.set_xticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_yticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_xlim(-2,2)\n",
+ "ax3.set_ylim(-2,2)\n",
+ "ax3.legend(loc='upper right')\n",
+ "ax3.set_title(r'$H(z)=A\\frac{z-2}{z-\\faktor{1}{2}}$',pad=20)\n",
+ "ax3.grid(True)\n",
+ "ax3.set_axisbelow(True)\n",
+ "\n",
+ "# time domain\n",
+ "\n",
+ "system = signal.dlti([z_zero1],[z_infty0],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax4.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "impulse2 = -3*A*(1/2)**k\n",
+ "ax4.plot(k,impulse2,ls=':',color='C0',clip_on=False)\n",
+ "\n",
+ "#ax4.set_xticks(np.arange(0,8))\n",
+ "ax4.set_yticks([-3*A,-3*A/2,-3*A/4,-3*A/8,0,A])\n",
+ "ax4.set_yticklabels(['$-3A$',r'$-\\faktor{3A}{2}$',r'$-\\faktor{3A}{4}$',r'$-\\faktor{3A}{8}$','$0$','$A$'])\n",
+ "\n",
+ "ax4.set_xlim(0,7)\n",
+ "ax4.set_ylim(-3*A,A)\n",
+ "\n",
+ "ax4.set_title(r'$h[k]=4A\\delta[k]-3A\\left(\\frac{1}{2}\\right)^k\\epsilon[k]$',pad=20)\n",
+ "ax4.set_xlabel('$k$')\n",
+ "ax4.grid(True)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "\"\"\"\n",
+ "ax3.fill_between(z,\n",
+ " np.zeros_like(z)-2.5,\n",
+ " np.zeros_like(z)+2.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "ax3.set_box_aspect(1)\n",
+ "\n",
+ "ax3.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax3.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax3.scatter(np.real(z_infty0),np.imag(z_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{\\infty,0}$',\n",
+ " (np.real(z_infty0),np.imag(z_infty0)),\n",
+ " (np.real(z_infty0),np.imag(z_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'right',\n",
+ " \n",
+ " )\n",
+ "\n",
+ "ax3.scatter(np.real(z_zero1),np.imag(z_zero1),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{0,1}$',\n",
+ " (np.real(z_zero1),np.imag(z_zero1)),\n",
+ " (np.real(z_zero1),np.imag(z_zero1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "ax3.text(0,-0.75*2,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax3.set_xticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_yticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_xlim(-2,2)\n",
+ "ax3.set_ylim(-2,2)\n",
+ "ax3.legend(loc='upper right')\n",
+ "ax3.set_title(r'$H(z)=A\\frac{z-\\left(\\faktor{1}{2}+\\sigma_0\\right)}{z-\\faktor{1}{2}}$',pad=20)\n",
+ "ax3.grid(True)\n",
+ "ax3.set_axisbelow(True)\n",
+ "\n",
+ "system = signal.dlti([z_zero1],[z_infty0],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax4.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "impulse2 = -2*A*sigma_0*(1/2)**k\n",
+ "ax4.plot(k,impulse2,ls=':',color='C0',clip_on=False)\n",
+ "ax4.annotate(text='',xy=(0,0),xytext=(0,A),\n",
+ " arrowprops=dict(arrowstyle='<-',\n",
+ " connectionstyle='arc3',\n",
+ " shrinkA=0,shrinkB=0,\n",
+ " ec='C0',fc='C0',\n",
+ " lw=1.5,\n",
+ " ls=':',\n",
+ " clip_on=False))\n",
+ "\n",
+ "#ax4.set_xticks(np.arange(0,8))\n",
+ "ax4.set_yticks([-2*A*sigma_0,-A*sigma_0,-A/2*sigma_0,-A/4*sigma_0,0,A])\n",
+ "ax4.set_yticklabels(['$-2A\\sigma_0$','$-A\\sigma_0$',r'$-\\faktor{A\\sigma_0}{2}$',r'$-\\faktor{A\\sigma_0}{4}$','$0$','$A$'])\n",
+ "\n",
+ "ax4.set_xlim(0,7)\n",
+ "ax4.set_ylim(-2*A*sigma_0,A)\n",
+ "\n",
+ "ax4.set_title(r'$h[k]=A\\delta[k]-2A\\sigma_0\\left(\\frac{1}{2}\\right)\\epsilon[k]$',pad=20)\n",
+ "ax4.set_xlabel('$k$')\n",
+ "ax4.grid(True)\n",
+ "\"\"\"\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# z-plane\n",
+ "\n",
+ "ax5.fill_between(z,\n",
+ " np.zeros_like(z)-2.5,\n",
+ " np.zeros_like(z)+2.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax5.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.add_patch(circle)\n",
+ "ax5.set_box_aspect(1)\n",
+ "\n",
+ "ax5.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax5.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax5.scatter(np.real(z_infty1),np.imag(z_infty1),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{\\infty,1}$',\n",
+ " (np.real(z_infty1),np.imag(z_infty1)),\n",
+ " (np.real(z_infty1),np.imag(z_infty1)+0.3),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " va = 'center',\n",
+ " \n",
+ " )\n",
+ "ax5.scatter(np.real(z_infty2),np.imag(z_infty2),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{\\infty,2}$',\n",
+ " (np.real(z_infty2),np.imag(z_infty2)),\n",
+ " (np.real(z_infty2),np.imag(z_infty2)-0.3),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " \n",
+ " )\n",
+ "ax5.scatter(np.real(z_zero2),np.imag(z_zero2),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{0,1}$',\n",
+ " (np.real(z_zero2),np.imag(z_zero2)),\n",
+ " (np.real(z_zero2)-0.1,np.imag(z_zero2)),\n",
+ " size='x-large',\n",
+ " ha = 'right',\n",
+ " va = 'center',\n",
+ " )\n",
+ "ax5.scatter(np.real(z_zero0),np.imag(z_zero0),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{0,0}$',\n",
+ " (np.real(z_zero0),np.imag(z_zero0)),\n",
+ " (np.real(z_zero0),np.imag(z_zero0)-0.25),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " va = 'center',\n",
+ " )\n",
+ "ax5.text(0,-0.75,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax5.set_xticks(np.arange(-1,1+1,1))\n",
+ "ax5.set_yticks(np.arange(-1,1+1,1))\n",
+ "ax5.set_xlim(-1,1)\n",
+ "ax5.set_ylim(-1,1)\n",
+ "ax5.legend(loc='upper right')\n",
+ "ax5.set_title(r'$H(z)=A\\frac{z\\left(z-\\faktor{1}{2}\\cos(\\Omega_0\\right)}{\\left(z-\\faktor{1}{2}\\e^{+\\im\\Omega_0}\\right)\\left(z-\\faktor{1}{2}\\e^{-\\im\\Omega_0}\\right)}$',pad=20)\n",
+ "ax5.grid(True)\n",
+ "ax5.set_axisbelow(True)\n",
+ "\n",
+ "# time domain\n",
+ "\n",
+ "system = signal.dlti([z_zero0,z_zero2],[z_infty1,z_infty2],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax6.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "h = r**k*np.cos(Omega_0*k)\n",
+ "ax6.plot(k,h,ls=':',color='C0',clip_on=False)\n",
+ "ax6.set_xticks(np.arange(8))\n",
+ "ax6.set_yticks([-A,-A/2,-A/4,0,A/4,A/2,A])\n",
+ "ax6.set_yticklabels(['$-A$',r'$- \\faktor{A}{2}$',r'$-\\faktor{A}{4}$','$0$',r'$+\\faktor{A}{4}$',r'$+\\faktor{A}{2}$','$+A$'])\n",
+ "\n",
+ "ax6.set_xlim(0,7)\n",
+ "ax6.set_ylim(-A,A)\n",
+ "ax6.set_title(r'$h[k]=\\left(\\frac{1}{2}\\right)^k\\cos[\\Omega_0 k]\\epsilon[k]$',pad=20)\n",
+ "ax6.set_xlabel('$k$')\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('zTrafo.pdf')"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.7"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/CITATION.cff b/CITATION.cff
new file mode 100644
index 0000000..0e55b76
--- /dev/null
+++ b/CITATION.cff
@@ -0,0 +1,24 @@
+message: "Please cite this work as below."
+authors:
+- family-names: "Hauser"
+ given-names: "Robert"
+- family-names: "Schultz"
+ given-names: "Frank"
+ orcid: "https://orcid.org/0000-0002-3010-0294"
+title: "Continous- and Discrete-Time Signals and Systems - Cheat Sheet"
+version: 1.0
+url: "https://github.com/spatialaudio/signals-and-systems-cheatsheet"
+preferred-citation:
+ type: manual
+ authors:
+ - family-names: "Hauser"
+ given-names: "Robert"
+ - family-names: "Schultz"
+ given-names: "Frank"
+ orcid: "https://orcid.org/0000-0002-3010-0294"
+ version: 1.0
+ title: "Continous- and Discrete-Time Signals and Systems - Cheat Sheet"
+ url: "https://github.com/spatialaudio/signals-and-systems-cheatsheet"
+ year: 2022
+ month: 5
+
diff --git a/literatur.bib b/literatur.bib
new file mode 100644
index 0000000..b0bf611
--- /dev/null
+++ b/literatur.bib
@@ -0,0 +1,14 @@
+@manual{sigsysex,
+ author = {Frank Schultz},
+ title = {{Continous- and Descrete-Time Signals and Systems - A Tutorial Featuring Computational Examples}},
+ organization = {University of Rostock},
+ url = {https://github.com/spatialaudio/signals-and-systems-exercises},
+ urldate = {2022-05-06}}
+
+@book{Bronstein,
+ author = {I.N. Bronshtein AND K.A. Semendyayev AND G. Musiol AND H. Mühlig},
+ title = {Handbook of Mathematics},
+ edition = {6},
+ publisher = {Springer Berlin, Heidelberg},
+ doi = {10.1007/978-3-662-46221-8},
+ year = {2015}}
diff --git a/sig_sys_macros.sty b/sig_sys_macros.sty
new file mode 100644
index 0000000..508154b
--- /dev/null
+++ b/sig_sys_macros.sty
@@ -0,0 +1,172 @@
+%This work is licensed under a Creative Commons Attribution 4.0 International License
+%
+%
This work is licensed under a Creative Commons Attribution 4.0 International License.
+%
+%###############################################################################
+%
+%Software in particular is licensed under the MIT License:
+%
+%Copyright (c) 2019 spatialaudio.net
+%
+%Permission is hereby granted, free of charge, to any person obtaining a copy
+%of this software and associated documentation files (the "Software"), to deal
+%in the Software without restriction, including without limitation the rights
+%to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+%copies of the Software, and to permit persons to whom the Software is
+%furnished to do so, subject to the following conditions:
+%
+%The above copyright notice and this permission notice shall be included in all
+%copies or substantial portions of the Software.
+%
+%THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+%IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+%FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+%AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+%LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+%OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+%SOFTWARE.
+
+
+
+\usetikzlibrary{calc}
+\usetikzlibrary{positioning}
+\usetikzlibrary{matrix}
+\usetikzlibrary{chains}
+\usetikzlibrary{shapes.misc}
+\tikzset{cross/.style={cross out, draw,minimum size=2*(#1-\pgflinewidth),inner sep=0pt, outer sep=0pt}}
+\pgfkeys{/pgfplots/axis style/.code={\pgfkeysalso{/pgfplots/every axis/.append style={#1}}}}
+\pgfplotsset{
+mathaxis/.style={
+axis lines=center,
+xtick=\empty,
+ytick=\empty,
+xlabel style=right,
+ylabel style=above,
+% Make sure the origin is shown (http://tex.stackexchange.com/a/91253)
+before end axis/.code={
+\addplot [draw=none, forget plot] coordinates {(0,0)};
+},
+anchor=origin,
+},
+stemaxis/.style={
+mathaxis,
+x=.8em,
+y=6ex,
+enlarge x limits={abs=1.2em},
+enlarge y limits={abs=1.2em},
+}
+}
+\tikzstyle{stem}=[ycomb,mark=*,mark size=10\pgflinewidth,color=C0,ultra thick]
+\tikzstyle{stem2}=[ycomb,mark=*,mark size=5\pgflinewidth,color=C0,ultra thick]
+
+\newcommand{\eq}[1]{Glg. (\ref{#1})} %ref equation
+\newcommand{\fig}[1]{Abb. \ref{#1}} %ref figure
+
+%math
+\newcommand\fsd{\mathrm{d}} %der/int operator
+\newcommand{\diff}{\mathrm{d}}
+\newcommand{\sysH}[1]{\mathcal{H}{\{#1\}}} % system operator
+\renewcommand{\vec}[1]{\mathbf{#1}} %vector
+
+%Sha symbol:
+\DeclareFontFamily{U}{wncy}{}
+\DeclareFontShape{U}{wncy}{m}{n}{<->wncyr10}{}
+\DeclareSymbolFont{mcy}{U}{wncy}{m}{n}
+\DeclareMathSymbol{\Sha}{\mathord}{mcy}{"58}
+%\newcommand{\Sha}{$\bot \!\! \bot \!\! \bot$}
+
+\DeclareMathOperator{\rectOP}{\text{rect}}
+\newcommand{\rectN}[2]{\ensuremath{\rectOP_{#1} \left[ #2 \right]}}
+
+%matplotlib colors:
+\definecolor{C0}{HTML}{1f77b4}
+\definecolor{C1}{HTML}{ff7f0e}
+\definecolor{C2}{HTML}{2ca02c}
+\definecolor{C3}{HTML}{d62728}
+\definecolor{C7}{HTML}{7f7f7f}
+%other useful colors:
+\newcommand{\red}{\textcolor{red}}
+\newcommand{\blue}{\textcolor{blue}}
+\newcommand{\ured}[1]{\textcolor{red}{\underline{#1}}}
+\newcommand{\ublue}[1]{\textcolor{blue}{\underline{#1}}}
+\newcommand{\ugreen}[1]{\textcolor{green}{\underline{#1}}}
+\newcommand{\uorange}[1]{\textcolor{orange}{\underline{#1}}}
+\newcommand{\umagenta}[1]{\textcolor{magenta}{\underline{#1}}}
+\newcommand{\ublack}[1]{\textcolor{black}{\underline{#1}}}
+\newcommand{\ubrown}[1]{\textcolor{brown}{\underline{#1}}}
+
+%transform symbols:
+%https://ctan.org/tex-archive/macros/latex/contrib/trfsigns?lang=en
+%needs \rmfamily instead of \rm in trfsigns package
+\renewcommand{\ztransf}{\mbox{\setlength{\unitlength}{0.1em}%
+ \begin{picture}(20,10)%
+ \put(2,3){\circle{4}}%
+ \put(4,3){\line(1,0){4.75}}%
+ \multiput(8.625,3.15)(0.25,0.25){11}{%
+ \makebox(0,0){\rmfamily\tiny .}}%
+ \put(17,3){\line(-1,0){5.75}}%
+ \put(18,3){\circle*{4}}%
+ \end{picture}%
+ }
+ }
+\renewcommand{\Ztransf}{\mbox{\setlength{\unitlength}{0.1em}%
+ \begin{picture}(20,10)%
+ \put(2,3){\circle*{4}}%
+ \put(3,3){\line(1,0){5.75}}%
+ \multiput(11.375,3.15)(-0.25,0.25){11}{%
+ \makebox(0,0){\rmfamily\tiny .}}%
+ \put(16,3){\line(-1,0){4.75}}%
+ \put(18,3){\circle{4}}%
+ \end{picture}%
+ }
+ }
+
+\newcommand{\dtft}{\mbox{\setlength{\unitlength}{0.1em}%
+ \begin{picture}(20,10)%
+ \put(2,3){\circle{4}}%
+ \put(4,3){\line(1,0){4.75}}%
+ \multiput(8.625,3.15)(0.25,0.25){11}{%
+ \makebox(0,0){\rmfamily\tiny .}}%
+ \put(17,3){\line(-1,0){5.75}}%
+ %\put(18,3){\circle*{4}}%
+ \end{picture}%
+ }
+ }
+\newcommand{\DTFT}{\mbox{\setlength{\unitlength}{0.1em}%
+ \begin{picture}(20,10)%
+ %\put(2,3){\circle*{4}}%
+ \put(3,3){\line(1,0){5.75}}%
+ \multiput(11.375,3.15)(-0.25,0.25){11}{%
+ \makebox(0,0){\rmfamily\tiny .}}%
+ \put(16,3){\line(-1,0){4.75}}%
+ \put(18,3){\circle{4}}%
+ \end{picture}%
+ }
+ }
+
+
+\newcommand{\mydft}{\mbox{\setlength{\unitlength}{0.1em}%
+ \begin{picture}(20,10)%
+ \put(2,3){\circle{4}}%
+ \put(4,3){\line(1,0){4.75}}%
+ \multiput(8.625,3.15)(0.25,0.25){11}{%
+ \makebox(0,0){\rmfamily\tiny .}}%
+ \put(17,3){\line(-1,0){5.75}}%
+ %\put(18,3){\circle*{4}}%
+ \put(6,-4){\scriptsize $N$}
+ \end{picture}%
+ }
+ }
+
+\newcommand{\myDFT}{\mbox{\setlength{\unitlength}{0.1em}%
+ \begin{picture}(20,10)%
+ %\put(2,3){\circle*{4}}%
+ \put(3,3){\line(1,0){5.75}}%
+ \multiput(11.375,3.15)(-0.25,0.25){11}{%
+ \makebox(0,0){\rmfamily\tiny .}}%
+ \put(16,3){\line(-1,0){4.75}}%
+ \put(18,3){\circle{4}}%
+ \put(6,-4){\scriptsize $N$}
+ \end{picture}%
+ }
+ }
diff --git a/signals-and-systems-cheatsheet.ipynb b/signals-and-systems-cheatsheet.ipynb
new file mode 100644
index 0000000..13163a3
--- /dev/null
+++ b/signals-and-systems-cheatsheet.ipynb
@@ -0,0 +1,2659 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "64ead2a4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "from scipy.signal import square\n",
+ "from scipy.special import diric\n",
+ "import matplotlib.colors as colors\n",
+ "import scipy.signal as signal\n",
+ "import sympy.integrals.transforms as transforms\n",
+ "from sympy import *\n",
+ "from sympy.solvers.solvers import solve\n",
+ "from IPython.display import display, Math\n",
+ "from matplotlib.patches import Circle\n",
+ "plt.rcParams.update({\n",
+ " \"text.usetex\" : True,\n",
+ " \"text.latex.preamble\" : r\"\\usepackage{amssymb} \\usepackage{amsmath} \\usepackage{faktor} \\newcommand{\\im}{\\mathrm{j}} \\newcommand{\\e}{\\mathrm{e}}\",\n",
+ " \"font.size\" : 11,\n",
+ "})"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d86015a1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def rect_impulse(t,Th):\n",
+ " x = np.zeros_like(t)\n",
+ " i = np.where((t >= -Th/2) & (t <= Th/2))\n",
+ " x[i] = 1\n",
+ " return x\n",
+ "\n",
+ "def tri_impulse(t,Th):\n",
+ " x = np.zeros_like(t)\n",
+ " i = np.where((t >= -Th/2) & (t <0))\n",
+ " x[i] = 2/Th*t[i]+1\n",
+ " i = np.where((t <= +Th/2) & (t >= 0))\n",
+ " x[i] = -2/Th*t[i]+1\n",
+ " return x\n",
+ "\n",
+ "def triangular_wave(t,T,Th,A):\n",
+ " t = np.mod(t,T)\n",
+ " x = np.zeros_like(t)\n",
+ " i = np.where(t <= Th/2)\n",
+ " x[i] = -2*A/Th*t[i]+A\n",
+ " i = np.where(t >= T-Th/2)\n",
+ " x[i] = 2*A/Th*t[i]+A*(1-2*T/Th)\n",
+ " return x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a803c473",
+ "metadata": {},
+ "source": [
+ "---\n",
+ "header-includes:\n",
+ " - \\usepackage{amssymb}\n",
+ " - \\usepackage{trfsigns}\n",
+ "---"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2e38b436",
+ "metadata": {},
+ "source": [
+ "$\\newcommand{\\e}{\\mathrm{e}}$\n",
+ "$\\newcommand{\\im}{\\mathrm{j}}$\n",
+ "$\\newcommand{\\sinc}{\\mathrm{sinc}}$\n",
+ "### Fourierkoeffizienten Rechteckschwingung\n",
+ "\\begin{gather}\n",
+ "\tX_0=2\\int_0^{\\frac{T_h}{2}}A\\mathrm{d}t \n",
+ "= 2At\\Bigg |_{t=0}^{t=\\frac{T_h}{2}}=A\\cdot T_h\\\\\n",
+ "\tX_\\mu=\\int_{-\\frac{T_h}{2}}^{\\frac{T_h}{2}}A\\e^{-\\im k \\omega_0 t}\\mathrm{d}t=\\frac{A}{\\im k \\omega_0}\\left(\\e^{\\im \\pi \\frac{T_h}{T}}-\\e^{-\\im \\pi \\mu \\frac{T_h}{T}}\\right)\\\\\n",
+ "\t=\\frac{AT}{\\im \\mu 2\\pi }\\left(\\e^{\\im \\pi \\mu \\frac{T_h}{T}}-\\e^{-\\im \\pi \\mu \\frac{T_h}{T}}\\right)\n",
+ "\t=\\frac{AT}{\\mu\\pi}\\sin(\\pi \\mu \\frac{T_h}{T})\\\\\n",
+ "\t=\\frac{AT}{\\mu\\pi}\\frac{T_h}{T_h}\\sin(\\pi \\mu \\frac{T_h}{T})={AT_h}\\frac{\\sin(\\pi \\mu \\frac{T_h}{T})}{\\pi \\mu \\frac{T_h}{T}}=A\\cdot T_h\\mathrm{sinc}(\\pi \\mu \\frac{T_h}{T})\n",
+ "\\end{gather}\n",
+ "### Faltung von $x(t)$ mit $y(t)$\n",
+ "\\begin{gather}\n",
+ "\tx(t)\\ast y(t)=\\begin{cases}\n",
+ "\t\t\\int_{t-T_h}^{-T+\\frac{T_h}{2}}\\frac{A^2}{2}\\mathrm{d}\\tau=\\frac{A^2}{2}\\left(-T+\\frac{T_h}{2}-t+T_h\\right)=-\\frac{A^2}{2}\\left(t+T-3\\frac{T_h}{2}\\right)&,-\\frac{T}{2}\\leq t \\leq -\\frac{T_h}{2}\\\\\n",
+ "\t\t\\int_{-\\frac{T_h}{2}}^{t}\\frac{A^2}{2}\\mathrm{d}\\tau=\\frac{A^2}{2}\\left(t+\\frac{T_h}{2}\\right)&,\\frac{-T_h}{2}\\leq t \\leq \\frac{T_h}{2} \\\\\n",
+ "\t\t\\int_{t-T_h}^{\\frac{T_h}{2}}\\frac{A^2}{2}\\mathrm{d}\\tau=\\frac{A^2}{2}\\left(\\frac{T_h}{2}-t+T_h\\right)=-\\frac{A^2}{2}\\left(t-3\\frac{T_h}{2}\\right)&,\\frac{T_h}{2}\\leq t \\leq \\frac{T}{2}\n",
+ "\t\\end{cases}\n",
+ "\\end{gather}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4199224a",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [],
+ "source": [
+ "#fourier series of square wave, time shifted square wave and convolution between these two\n",
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "t = np.arange(-5,5+1/1000,1/1000)\n",
+ "k = np.arange(-500,501)\n",
+ "kk, tt = np.meshgrid(k,t)\n",
+ "w = np.exp(1j*kk*tt*2*np.pi/T)\n",
+ "\n",
+ "\n",
+ "x = A*(square((t+Th/2)/T*2*np.pi,duty=Th/T)+1)/2\n",
+ "y= A/2*(square((t)/T*2*np.pi,duty=Th/T)+1)/2\n",
+ "z = A*Th*np.sinc(kk*Th/T)*1/2*A*Th*np.sinc(kk*Th/T)*np.exp(-1j*2*np.pi/T*kk*Th/2)*w\n",
+ "z = np.reshape(z, (t.size,k.size))\n",
+ "z = 1/T*np.sum(z,axis=1)\n",
+ "z = np.real(z)\n",
+ "\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T_0$','$-T_0$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T_0$','$+2T_0$'])\n",
+ "ax.set_xlabel('$t$')\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_title(r'$x(t)=\\mathrm{rect}\\left(\\frac{t}{T_h}\\right),\\quad\\quad x(t)=x(t+T_0),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "\n",
+ "k = np.arange(-5,6,1)\n",
+ "X = A*Th*np.sinc(k*Th/T)\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "X_ph = np.angle(X)\n",
+ "i = np.where(k >0,1,0)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i==True)\n",
+ "X_ph[i] = -np.pi\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\left|\\tilde{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\left|\\tilde{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\left|\\tilde{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,X_ph,marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\varphi\\left(\\tilde{X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\varphi\\left(\\tilde{Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\varphi\\left(\\tilde{Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "# gestrichelte Linie zeichnen\n",
+ "\n",
+ "k = np.arange(-5,5+1/1000,1/1000)\n",
+ "X = A*Th*np.sinc(k*Th/T)\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "X_ph = np.angle(X)\n",
+ "i = np.where(k>0,1,10)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_ph[i] *= (-1)*np.sign(k)[i]\n",
+ "\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,X_ph,ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "xticks = np.arange(-5,5+1,1)\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "labels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-5,5)\n",
+ "ax2.set_xlim(-5,5)\n",
+ "ax3.set_xlim(-5,5)\n",
+ "ax4.set_xlim(-5,5)\n",
+ "ax5.set_xlim(-5,5)\n",
+ "ax6.set_xlim(-5,5)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th+A*Th/2,A*Th/2))\n",
+ "ax1.set_yticklabels(['0',r'$\\faktor{AT_h}{2}$',\n",
+ " '$A T_h$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{4}$',\n",
+ " r'$\\faktor{A T_h}{2}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/2+A**2*Th**2/4,A**2*Th**2/4))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{4}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(labels)\n",
+ "ax5.set_yticklabels(labels)\n",
+ "ax6.set_yticklabels(labels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=12,loc='center right')\n",
+ "ax2.legend(fontsize=12,loc='center right')\n",
+ "ax3.legend(fontsize=12,loc='center right')\n",
+ "ax4.legend(fontsize=12,loc='upper right')\n",
+ "ax5.legend(fontsize=12,loc='upper right')\n",
+ "ax6.legend(fontsize=12,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('fourier_series_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2b3797b1",
+ "metadata": {},
+ "source": [
+ "$\\newcommand{\\e}{\\mathrm{e}}$\n",
+ "$\\newcommand{\\im}{\\mathrm{j}}$\n",
+ "$\\newcommand{\\sinc}{\\mathrm{sinc}}$\n",
+ "### Fourierkoeffizienten Dreieckschwingung\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\tX_\\mu = \\int_{-\\frac{T_h}{2}}^{+\\frac{T_h}{2}}x(t)\\e^{-\\im \\mu \\omega t}\\mathrm{d}t=\\int_{-\\frac{T_h}{2}}^0\\left(\\frac{2A}{T_h}t+A\\right)\\e^{-\\im \\mu \\omega t}\\mathrm{d}t+\\int_0^{+\\frac{T_h}{2}}\\left(-\\frac{2A}{T_h}t+A\\right)\\e^{-\\im \\mu \\omega t}\\mathrm{d}t\\\\\n",
+ "\t=\\frac{\\left(\\frac{2A}{T_h}t+A\\right)}{-\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\Bigg|_{t=-\\frac{T_h}{2}}^{0}+\\int_{-\\frac{T_h}{2}}^0\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\mathrm{d}t+\\frac{\\left(-\\frac{2A}{T_h}t+A\\right)}{-\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\Bigg|_{t=0}^{+\\frac{T_h}{2}}-\\int_0^{+\\frac{T_h}{2}}\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\im \\mu \\omega }\\e^{-\\im \\mu \\omega t}\\mathrm{d}t\\\\\n",
+ "\t=-\\frac{A}{\\im \\mu \\omega }+\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\mu^2\\omega^2}\\e^{-\\im \\mu \\omega t}\\Bigg |_{t=-\\frac{T_h}{2}}^{t=0}+\\frac{A}{\\im \\mu \\omega}+\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\mu^2\\omega^2}\\e^{-\\im \\mu \\omega t}\\Bigg |_{t=+\\frac{T_h}{2}}^{t=0}\\\\\n",
+ "\t=\\frac{\\left(\\frac{2A}{T_h}\\right)}{\\mu^2\\omega^2}\\left[2-\\e^{\\im \\mu \\omega \\frac{T_h}{2}}-\\e^{-\\im \\mu \\omega \\frac{T_h}{2}}\\right]=\\frac{\\left(\\frac{4A}{T_h}\\right)}{\\mu^2\\omega^2}\\left[1-\\cos(\\mu\\pi\\frac{T_h}{T})\\right]\n",
+ "\\end{gather}\n",
+ "Es gilt (S. 83 in I. Bronshtein, K. Semendyayev, G. Musiol, and H. Mühlig, Handbook of\n",
+ "Mathematics, 6th ed. Springer Berlin, Heidelberg, 2015.):\n",
+ "\\begin{gather}\n",
+ "\t\\sin^2(\\alpha)=\\frac{1}{2}(1-\\cos(2\\alpha))\n",
+ "\\end{gather}\n",
+ "Also:\n",
+ "\\begin{gather}\n",
+ "\t\\frac{\\left(\\frac{4A}{T_h}\\right)}{\\mu^2\\omega^2}\\left[1-\\cos(\\mu\\pi\\frac{T_h}{T})\\right]=\\frac{\\left(\\frac{4AT^2}{T_h}\\right)}{\\mu^24\\pi^2}\\left[1-\\cos(\\mu\\pi\\frac{T_h}{T})\\right]=\\frac{2AT^2}{T_h\\mu^2\\pi^2}\\cdot\\frac{1}{2}\\left[1-\\cos\\left(2\\mu\\pi\\frac{T_h}{2T}\\right)\\right]\\\\\n",
+ "\t=\\frac{2AT^2}{T_h\\mu^2\\pi^2}\\left[\\sin^2\\left(\\mu\\pi\\frac{T_h}{2T}\\right)\\right]=\\frac{T_hA}{2}\\frac{4T^2}{T_h^2\\mu^2\\pi^2}\\left[\\sin^2\\left(\\mu\\pi\\frac{T_h}{2T}\\right)\\right]=\\frac{A\\cdot T_h}{2}\\sinc^2\\left(\\mu\\pi\\frac{T_h}{2T}\\right)\n",
+ "\\end{gather}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "dd807a53",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "k = np.arange(-500,501)\n",
+ " \n",
+ "ax = fig.add_subplot(311)\n",
+ "ax.set_xlabel('$t$')\n",
+ "\n",
+ "x = triangular_wave(t=t,T=T,Th=Th,A=A)\n",
+ "y = triangular_wave(t=t-Th/2,T=T,Th=Th,A=A)/2\n",
+ "\n",
+ "z = A*Th/2*np.sinc(kk*Th/(2*T))**2*1/2*A*Th/2*np.sinc(kk*Th/(2*T))**2*np.exp(-1j*2*np.pi/T*kk*Th/2)*w\n",
+ "z = np.reshape(z, (t.size,k.size))\n",
+ "z = 1/T*np.sum(z,axis=1)\n",
+ "z = np.real(z)\n",
+ "\n",
+ "\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T_0$','$-T_0$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T_0$','$+2T_0$'])\n",
+ "\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_title(r'$x(t)=\\mathrm{tri}\\left(2\\frac{t}{T_h}\\right),\\quad\\quad x(t)=x(t+T_0),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "\n",
+ "k = np.arange(-5,5+1,1)\n",
+ "X = A*Th/2*np.sinc(k*Th/(2*T))**2\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\left|\\tilde{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\left|\\tilde{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\left|\\tilde{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,np.angle(X),marker='o',ls='',mec=color1,mfc=color1,\n",
+ " label=r'$\\varphi\\left(\\tilde{X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),marker='o',ls='',mec=color1,mfc=color2,\n",
+ " label=r'$\\varphi\\left(\\tilde{Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),marker='o',ls='',mec=color1,mfc=color3,\n",
+ " label=r'$\\varphi\\left(\\tilde{Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "k = np.arange(-5,5+1/1000,1/1000)\n",
+ "X = A*Th/2*np.sinc(k*Th/(2*T))**2\n",
+ "Y = X*np.exp(-2j*np.pi/T*k*Th/2)/2\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1.plot(k,np.abs(X),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,np.angle(X),ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "xticks = np.arange(-5,5+1,1)\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "labels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-5,5)\n",
+ "ax2.set_xlim(-5,5)\n",
+ "ax3.set_xlim(-5,5)\n",
+ "ax4.set_xlim(-5,5)\n",
+ "ax5.set_xlim(-5,5)\n",
+ "ax6.set_xlim(-5,5)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax1.set_yticklabels(['0',r'$\\faktor{A T_h}{4}$',\n",
+ " r'$\\faktor{A T_h}{2}$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/4+A*Th/8,A*Th/8))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{8}$',\n",
+ " r'$\\faktor{A T_h}{4}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/8+A**2*Th**2/16,A**2*Th**2/16))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{16}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{8}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(labels)\n",
+ "ax5.set_yticklabels(labels)\n",
+ "ax6.set_yticklabels(labels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('fourier_series_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6df56812",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "# time domain\n",
+ "t = np.arange(-5,5+1/1000,1/1000)\n",
+ "x = rect_impulse(t,Th)*A\n",
+ "y = rect_impulse(t-Th/2,Th)*A/2\n",
+ "z = np.zeros_like(t)\n",
+ "i = np.where((-Th/2<=t) & (t < Th/2))\n",
+ "z[i] = A**2/2*(t[i]+Th/2)\n",
+ "i = np.where((Th/2 <= t) & (t < 3*Th/2))\n",
+ "z[i] = A**2/2*(-t[i]+3*Th/2)\n",
+ "\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "# axis settings\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T$','$-T$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T$','$+2T$'])\n",
+ "\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_xlabel('$t$')\n",
+ "ax.set_title(r'$x(t)=\\mathrm{rect}\\left(\\frac{t}{T_h}\\right),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "\n",
+ "omega = np.arange(-5*2*np.pi/T,5*2*np.pi/T+1/1000,1/1000)\n",
+ "X = np.sinc(omega/2*Th/np.pi)*Th*A\n",
+ "Y = np.sinc(omega/2*Th/np.pi)*Th*A/2*np.exp(-1j*omega*Th/2)\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "\n",
+ "# swap pi with -pi for omega > 0 (point reflection)\n",
+ "X_ph = np.angle(X)\n",
+ "i = np.where(omega > 0,1,0)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_ph[i] = -np.pi\n",
+ "\n",
+ "# plot FT magnitude\n",
+ "ax1.plot(omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot FT phase\n",
+ "ax4.plot(omega,X_ph,color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left(\\tilde{Z}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "# axis settings for frequency domain\n",
+ "xticks = np.arange(-5*2*np.pi/T,+5*2*np.pi/T+2*np.pi/T,2*np.pi/T)\n",
+ "xlabels = ['$-5\\omega_0$','','','$-2\\omega_0$','','$0$',\n",
+ " '','$2\\omega_0$','','','$5\\omega_0$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax2.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax3.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax4.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax5.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax6.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "ax1.set_xlabel('$\\omega$')\n",
+ "ax2.set_xlabel('$\\omega$')\n",
+ "ax3.set_xlabel('$\\omega$')\n",
+ "ax4.set_xlabel('$\\omega$')\n",
+ "ax5.set_xlabel('$\\omega$')\n",
+ "ax6.set_xlabel('$\\omega$')\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th+A*Th/2,A*Th/2))\n",
+ "ax1.set_yticklabels(['0',r'$\\faktor{A T_h}{2}$',\n",
+ " r'$A T_h$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{4}$',\n",
+ " r'$\\faktor{A T_h}{2}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/2+A**2*Th**2/4,A**2*Th**2/4))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{4}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('continuous_fouriertrafo_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b4a8bfc2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "\n",
+ "# time domain\n",
+ "t = np.arange(-5,5+1/1000,1/1000)\n",
+ "x = tri_impulse(t,Th)*A\n",
+ "y = tri_impulse(t-Th/2,Th)*A/2\n",
+ "z = np.convolve(x,y)/1000\n",
+ "t2 = np.arange(-5*2,2*(5+1/1000),1/1000)\n",
+ "i = np.where((t2 >= -5) & (t2 <= 5))\n",
+ "z = z[i]\n",
+ "t2 = t2[i]\n",
+ "\n",
+ "# axis settings\n",
+ "ax.set_xlabel('$t$')\n",
+ "ax.plot(t,x,color=color1,label='$x(t)$',clip_on=False)\n",
+ "ax.plot(t,y,color=color2,label=r'$y(t)=\\frac{1}{2}x\\left(t-\\frac{T_h}{2}\\right)$',clip_on=False)\n",
+ "ax.plot(t2,z,color=color3,label=r'$z(t)=x(t)\\ast y(t)$',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks([-2*T,-T,-Th/2,0,Th/2,T,2*T])\n",
+ "ax.set_xticklabels(labels=['$-2T$','$-T$',r'$-\\faktor{T_h}{2}$','$0$',r'$+\\faktor{T_h}{2}$','$+T$','$+2T$'])\n",
+ "\n",
+ "\n",
+ "ax.set_ylim(0,A)\n",
+ "ax.set_yticks(np.arange(0,A+A/2,A/2))\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax.set_title(r'$x(t)=\\mathrm{tri}\\left(2\\frac{t}{T_h}\\right),\\quad\\quad 0<\\frac{T_h}{T}\\leq 1$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "omega = np.arange(-5*2*np.pi/T,5*2*np.pi/T+1/1000,1/1000)\n",
+ "X = A*Th/2*np.sinc(omega/4*Th/np.pi)**2\n",
+ "Y = A*Th/4*np.sinc(omega/4*Th/np.pi)**2*np.exp(-1j*omega*Th/2)\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "\n",
+ "# plot FT magnitude\n",
+ "ax1.plot(omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot FT phase\n",
+ "\n",
+ "ax4.plot(omega,np.angle(X),color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left(\\omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "# axis settings\n",
+ "\n",
+ "xticks = np.arange(-5*2*np.pi/T,+5*2*np.pi/T+2*np.pi/T,2*np.pi/T)\n",
+ "xlabels = ['$-5\\omega_0$','','','$-2\\omega_0$','','$0$',\n",
+ " '','$2\\omega_0$','','','$5\\omega_0$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax2.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax3.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax4.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax5.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "ax6.set_xlim(-5*2*np.pi/T,5*2*np.pi/T)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "ax1.set_xlabel('$\\omega$')\n",
+ "ax2.set_xlabel('$\\omega$')\n",
+ "ax3.set_xlabel('$\\omega$')\n",
+ "ax4.set_xlabel('$\\omega$')\n",
+ "ax5.set_xlabel('$\\omega$')\n",
+ "ax6.set_xlabel('$\\omega$')\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,A*Th/2+A*Th/4,A*Th/4))\n",
+ "ax1.set_yticklabels(['0',r'$\\frac{A T_h}{4}$',\n",
+ " r'$\\frac{A T_h}{2}$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,A*Th/4+A*Th/8,A*Th/8))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A T_h}{8}$',\n",
+ " r'$\\faktor{A T_h}{4}$'])\n",
+ "ax3.set_yticks(np.arange(0,A**2*Th**2/8+A**2*Th**2/16,A**2*Th**2/16))\n",
+ "ax3.set_yticklabels(['0',r'$\\faktor{A^2 T_h^2}{16}$',\n",
+ " r'$\\faktor{A^2 T_h^2}{8}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('continuous_fouriertrafo_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "145aac8f",
+ "metadata": {},
+ "source": [
+ "ẞ"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "e1fcf0b0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "# time domain\n",
+ "k = np.arange(-Th/2,Th+Th/4,Th/4)\n",
+ "x = rect_impulse(k,Th)*A\n",
+ "y = rect_impulse(k-Th/2,Th)*A/2\n",
+ "z = np.convolve(x,y)\n",
+ "k2 = np.arange(-Th,2*Th+Th/4,Th/4)\n",
+ "\n",
+ "ax.plot(k,x,label='$x[k]$',\n",
+ " mfc=color1,mec=color1,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-2]$',\n",
+ " mfc=color2,mec=color2,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k2,z,label=r'$z[k]=x[k]\\ast y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls=':',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "#gestrichelte Linien zwischen den Samples\n",
+ "\n",
+ "k = np.arange(-2*T,2*T+1/1000,1/1000)\n",
+ "x = rect_impulse(k,Th)*A\n",
+ "y = rect_impulse(k-Th/2,Th)*A/2\n",
+ "\n",
+ "ax.plot(k,x,ls=':',color=color1)\n",
+ "ax.plot(k,y,ls=':',color=color2)\n",
+ "\n",
+ "\n",
+ "#Abwechselnde Farben der Samples\n",
+ "k = np.arange(7*Th/4,2*T+0.01,3*Th/4)\n",
+ "k = np.append(k,np.arange(-2*T+Th/4,-3*Th/4+Th/4,3*Th/4))\n",
+ "plt.plot(k,np.zeros_like(k),ls='',marker='o',mec=color1,mfc=color1,clip_on=False)\n",
+ "\n",
+ "k = np.arange(9*Th/4,2*T,3*Th/4)\n",
+ "k = np.append(k,np.arange(-2*T+Th/2,-3*Th/4+Th/4,3*Th/4))\n",
+ "plt.plot(k,np.zeros_like(k),ls='',marker='o',mec=color3,mfc=color3,clip_on=False)\n",
+ "\n",
+ "k = np.arange(8*Th/4,2*T,3*Th/4)\n",
+ "k = np.append(k,np.arange(-2*T,-3*Th/4+Th/4,3*Th/4))\n",
+ "plt.plot(k,np.zeros_like(k),ls='',marker='o',mec=color2,mfc=color2,clip_on=False)\n",
+ "#axis settings\n",
+ "ax.set_xlabel('$k$')\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks(np.arange(-2*T,2*T+Th/4,Th/2))\n",
+ "labels = []\n",
+ "for i in np.arange(-2*T,2*T+Th/4,Th/2):\n",
+ " labels += ['$'+str(int(4*i/Th))+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "\n",
+ "ax.set_ylim(0,5*A**2/2)\n",
+ "ax.set_yticks([0,5*A**2/2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$'])\n",
+ "ax.set_title(r'x[k]=$\\mathrm{rect}_5[k-2]$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "#frequency domain\n",
+ "Omega = np.arange(-2*np.pi,2*np.pi+1/10000,1/10000)\n",
+ "X=A*5*diric(Omega,5)\n",
+ "Y=X/2*np.exp(-2j*Omega)\n",
+ "Z=X*Y\n",
+ "\n",
+ "X_ph = np.angle(X)\n",
+ "# swap pi to - pi for 0 <= Omega mod 2pi <= pi (point reflection)\n",
+ "i = np.where(np.mod(Omega,2*np.pi)<=np.pi,1,0)\n",
+ "j = np.where(X_ph==np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_ph[i] = -np.pi\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\Omega$')\n",
+ "ax2.set_xlabel('$\\Omega$')\n",
+ "ax3.set_xlabel('$\\Omega$')\n",
+ "ax4.set_xlabel('$\\Omega$')\n",
+ "ax5.set_xlabel('$\\Omega$')\n",
+ "ax6.set_xlabel('$\\Omega$')\n",
+ "\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(Omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(Omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega,X_ph,color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(Omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(Omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "# axis settings\n",
+ "xticks = np.arange(-2*np.pi,2*np.pi+np.pi/2,np.pi)\n",
+ "xlabels = ['$-2\\pi$','$-\\pi$','$0$','$+\\pi$','$+2\\pi$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-np.pi,+np.pi)\n",
+ "ax2.set_xlim(-np.pi,+np.pi)\n",
+ "ax3.set_xlim(-np.pi,+np.pi)\n",
+ "ax4.set_xlim(-np.pi,+np.pi)\n",
+ "ax5.set_xlim(-np.pi,+np.pi)\n",
+ "ax6.set_xlim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,5*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$','$4A$','$5A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,5*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$',r'$2A$',r'$\\faktor{5A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,25*A**2/2+5*A**2/2,5*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$','$5A^2$',r'$\\faktor{15A^2}{2}$','$10A^2$',r'$\\faktor{25A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DTFT_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "eb130459",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "# time domain\n",
+ "k = np.arange(-2*T,2*T+0.0001,Th/6)\n",
+ "x = tri_impulse(k,Th)*A\n",
+ "y = tri_impulse(k-Th/2,Th)*A/2\n",
+ "z = np.convolve(x,y)\n",
+ "k2 = np.arange(-4*T,4*T+0.000001,Th/6)\n",
+ "z = z[np.where(np.abs(k2)<=2*T+0.00000001)]\n",
+ "\n",
+ "\n",
+ "ax.plot(k,x,label='$x[k]$',color=color1,\n",
+ " mfc=color1,mec=color1,ls=':',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-3]$',color=color2,\n",
+ " mfc=color2,mec=color2,ls=':',marker='o',clip_on=False)\n",
+ "ax.plot(k,z,label=r'$z[k]=x[k]\\ast y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls=':',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "\n",
+ "#Abwechselnde Farben der Samples\n",
+ "k = np.append(np.arange(7,24+0.0000001,3),np.arange(-1,-24-0.0000001,-3))\n",
+ "plt.plot(k*Th/6,np.zeros_like(k),ls='',marker='o',mec=color1,mfc=color1,clip_on=False)\n",
+ "\n",
+ "k = np.append(np.arange(6,24+0.0000001,3),np.arange(0,-24-0.00001,-3))\n",
+ "plt.plot(k*Th/6,np.zeros_like(k),ls='',marker='o',mec=color2,mfc=color2,clip_on=False)\n",
+ "\n",
+ "k = np.append(np.arange(8,24+0.0000001,3),np.arange(-2,-24-0.0000001,-3))\n",
+ "plt.plot(k*Th/6,np.zeros_like(k),ls='',marker='o',mec=color3,mfc=color3,clip_on=False)\n",
+ "# axis settings\n",
+ "ax.set_xlim(-5,5)\n",
+ "ax.set_xticks(np.arange(-5,6,1))\n",
+ "\n",
+ "ax.set_xticks(np.arange(-24,24+0.0000001,3)*Th/6)\n",
+ "labels = []\n",
+ "for i in np.arange(-24,24+0.0000001,3,dtype=int):\n",
+ " labels += ['$'+str(i)+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "ax.set_xlabel('$k$')\n",
+ "ax.set_ylim(0,19/18*A**2)\n",
+ "ax.set_yticks([0,19/18*A**2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{19A^2}{18}$'])\n",
+ "ax.set_title(r'$x[k]=\\mathrm{tri}_3[k]$',pad=20)\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "Omega = np.arange(-2*np.pi,2*np.pi+1/10000,1/10000)\n",
+ "X = A*diric(Omega,3)**2*3\n",
+ "Y = X/2*np.exp(-3j*Omega)\n",
+ "Z = X*Y\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\Omega$')\n",
+ "ax2.set_xlabel('$\\Omega$')\n",
+ "ax3.set_xlabel('$\\Omega$')\n",
+ "ax4.set_xlabel('$\\Omega$')\n",
+ "ax5.set_xlabel('$\\Omega$')\n",
+ "ax6.set_xlabel('$\\Omega$')\n",
+ "\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega,np.abs(X),color=color1,\n",
+ " label=r'$\\left|{X}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(Omega,np.abs(Y),color=color2,\n",
+ " label=r'$\\left|{Y}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(Omega,np.abs(Z),color=color3,\n",
+ " label=r'$\\left|{Z}\\left(\\Omega\\right)\\right|$',\n",
+ " clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega,np.angle(X),color=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(Omega,np.angle(Y),color=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(Omega,np.angle(Z),color=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left(\\Omega\\right)\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "# axis settings\n",
+ "xticks = np.arange(-2*np.pi,2*np.pi+np.pi/2,np.pi)\n",
+ "xlabels = ['$-2\\pi$','$-\\pi$','$0$','$+\\pi$','$+2\\pi$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "\n",
+ "ax1.set_xlim(-np.pi,+np.pi)\n",
+ "ax2.set_xlim(-np.pi,+np.pi)\n",
+ "ax3.set_xlim(-np.pi,+np.pi)\n",
+ "ax4.set_xlim(-np.pi,+np.pi)\n",
+ "ax5.set_xlim(-np.pi,+np.pi)\n",
+ "ax6.set_xlim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,3*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,3*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,9*A**2/2+3*A**2/2,3*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{3A^2}{2}$','$3A^2$',r'$\\faktor{9A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DTFT_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "e54d900b",
+ "metadata": {},
+ "source": [
+ "---\n",
+ "header-includes:\n",
+ " - \\usepackage{amssymb}\n",
+ " - \\usepackage{trfsigns}\n",
+ "---\n",
+ "DTFT eines Dreieickes:\n",
+ "Faltung von $\\mathrm{rect}_[k]$ mit sich selbst ergibt ein Dreieck der Länge\n",
+ "2N+1$ mit Maximum bei N-1.\n",
+ "\n",
+ "DTFT durch Multiplikation der DTFTs des Rechtecksignals:\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\t\\mathrm{rect}_N[k]\\ast\\mathrm{rect}_N[k]\\quad\\fourier\\quad\\e^{-\\im\\Omega(N-1)}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ "\\end{gather}\n",
+ "\n",
+ "Mittelpunkt des Dreiecks soll bei 0 liegen, also Verschiebung um $N-1$ nach \n",
+ "links.\n",
+ "\n",
+ "Durch Faltung steigt das Dreieck jeweils um 1 bis zu einem Maximum \n",
+ "bei $N-1$ von $N$.\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\tN\\cdot \\mathrm{tri}_{N}[k]=\\e^{-\\im\\Omega(N-1)}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\\cdot\\e^{+j\\Omega(N-1)}=\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ "\\end{gather}\n",
+ "\n",
+ "N muss noch auf die andere Seite gebracht werden.\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\t\\mathrm{tri}_{N}[k]\\quad\\fourier\\quad\\frac{1}{N}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ "\\end{gather}\n",
+ "\n",
+ "Dies ist eine Korrespondenz für einen Dreiecksimpuls der Länge $2N+1$ (bzw. $2N-1$, wenn die Nullen an den Rändern nicht mitgezählt werden) mit der\n",
+ "Spitze bei $k=0$.\n",
+ "\n",
+ "\\begin{gather}\n",
+ "\t\\mathrm{tri}_N[k]=\n",
+ "\t\\begin{cases}\n",
+ "\t\t1-\\frac{k}{N}, &0 \\leq k \\leq N-1,\\\\\n",
+ "\t\t1+\\frac{k}{N}, &-N+1\\leq k < 0,\\\\\n",
+ "\t\t0, &\\text{sonst}.\n",
+ "\t\\end{cases}\n",
+ "\\end{gather}\n",
+ "\n",
+ "\n",
+ "\n",
+ "\\begin{gather}\n",
+ " \\lim\\limits_{\\Omega\\rightarrow0}\\frac{1}{N}\\cdot\\frac{\\sin^2(N\\frac{\\Omega}{2})}{\\sin^2(\\frac{\\Omega}{2})}\n",
+ " =\\lim\\limits_{\\Omega\\rightarrow0}\\frac{1}{N}\\cdot\\frac{2\\sin\\left(N\\frac{\\Omega}{2}\\right)\\cos\\left(N\\frac{\\Omega}{2}\\right)\\frac{N}{2}}{2\\sin\\left(\\frac{\\Omega}{2}\\right)\\cos\\left(\\frac{\\Omega}{2}\\right)\\frac{1}{2}}\\\\\n",
+ "\t=\\lim\\limits_{\\Omega\\rightarrow0}\n",
+ "\t\\frac{\n",
+ "\t\t\\cos^2\\left(N\\frac{\\Omega}{2}\\right)\\frac{N}{2}-\\sin^2\\left(N\\frac{\\Omega}{2}\\right)\\frac{N}{2}\n",
+ "\t}\n",
+ "\t{\n",
+ "\t\t\\cos^2\\left(\\frac{\\Omega}{2}\\right)\\frac{1}{2}-\\sin^2\\left(\\frac{\\Omega}{2}\\right)\\frac{1}{2}\n",
+ "\t}\n",
+ "\t=N\n",
+ "\\end{gather}\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b5cecf4d",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(9,7))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "# time domain\n",
+ "\n",
+ "k = np.arange(0,8,1/1000)\n",
+ "x = A*(square((k+2)/8*2*np.pi,0.5)+1)/2\n",
+ "y = A/2*(square(k/8*2*np.pi,0.5)+1)/2\n",
+ "\n",
+ "ax.plot(k,x,ls='--',color=color1,clip_on=False)\n",
+ "ax.plot(k,y,ls='--',color=color2,clip_on=False)\n",
+ "\n",
+ "k = np.arange(-16,0,1/1000)\n",
+ "x = A*(square((k+2)/8*2*np.pi,0.5)+1)/2\n",
+ "y = A/2*(square(k/8*2*np.pi,0.5)+1)/2\n",
+ "\n",
+ "ax.plot(k,x,ls=':',color=color1,clip_on=False)\n",
+ "ax.plot(k,y,ls=':',color=color2,clip_on=False)\n",
+ "\n",
+ "k = np.arange(8,16+1/1000,1/1000)\n",
+ "x = A*(square((k+2)/8*2*np.pi,0.5)+1)/2\n",
+ "y = A/2*(square(k/8*2*np.pi,0.5)+1)/2\n",
+ "\n",
+ "ax.plot(k,x,ls=':',color=color1,clip_on=False)\n",
+ "ax.plot(k,y,ls=':',color=color2,clip_on=False)\n",
+ "\n",
+ "k = np.arange(0,8,dtype=float)\n",
+ "x = np.zeros_like(k)\n",
+ "y = np.zeros_like(k)\n",
+ "\n",
+ "np.put(x,[0,1,2,6,7],A)\n",
+ "#np.put(x,[3,9],A/2)\n",
+ "np.put(y,[0,1,2,3,4],A/2)\n",
+ "#np.put(y,[0,6],A/4)\n",
+ "z = np.real(np.fft.ifft(np.fft.fft(x)*np.fft.fft(y)))\n",
+ "\n",
+ "\n",
+ "#plot period 2, 3 (first element)\n",
+ "k2 = np.append(np.append(k-16,k-8),k[0])\n",
+ "x2 = np.append(np.append(x,x),x[0])\n",
+ "y2 = np.append(np.append(y,y),y[0])\n",
+ "z2 = np.append(np.append(z,z),z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls='',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls='',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "#plot period -2 and -1\n",
+ "\n",
+ "k2 = np.append(k[k.size-1],np.append(k+8,k[0]+16))\n",
+ "x2 = np.append(x[x.size-1],np.append(x,x[0]))\n",
+ "y2 = np.append(y[y.size-1],np.append(y,y[0]))\n",
+ "z2 = np.append(z[z.size-1],np.append(z,z[0]))\n",
+ "\n",
+ "ax.plot(k2,x2,ls='',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls='',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "#plot period 1\n",
+ "ax.plot(k,x,label='$x[k]$',color=color1,\n",
+ " mfc=color1,mec=color1,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-2]$',color=color2,\n",
+ " mfc=color2,mec=color2,ls='',marker='o',clip_on=False)\n",
+ "ax.plot(k,z,label=r'$z[k]=x[k]\\circledast_{8} y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls='--',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "# axis settings\n",
+ "\n",
+ "ax.set_xlabel('$k$')\n",
+ "ax.set_xlim(-16,16)\n",
+ "ax.set_xticks(np.arange(-16,16+2,2))\n",
+ "\n",
+ "labels = []\n",
+ "for i in np.arange(-16,16+2,2):\n",
+ " labels += ['$'+str(i)+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "\n",
+ "ax.set_ylim(0,5*A**2/2)\n",
+ "ax.set_yticks([0,5*A**2/2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$'])\n",
+ "ax.set_title(r'$x[k]=\\mathrm{rect}_5[(k-2) \\bmod 8]$')\n",
+ "ax.grid(True)\n",
+ "##########################################\n",
+ "# frequency domain\n",
+ "X = np.fft.fft(x)\n",
+ "Y = np.fft.fft(y)\n",
+ "Z = X*Y\n",
+ "\n",
+ "X_ph = np.angle(X)\n",
+ "X_ph[2] = -np.pi\n",
+ "X_ph[3] = -np.pi\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "##########################################\n",
+ "# plot DTFT magnitude/phase for -2pi <= Omega <= 0\n",
+ "Omega = np.arange(0,2*np.pi+1/1000,1/1000)\n",
+ "X_dtft = A*diric(Omega,5)*5\n",
+ "Y_dtft = X_dtft/2*np.exp(-2j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "X_dtft_ph = np.angle(X_dtft)\n",
+ "# exchange pi to -pi for point reflection (DTFT phase)\n",
+ "i = np.where(Omega <= np.pi,1,0)\n",
+ "j = np.where(X_dtft_ph == np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_dtft_ph[i] = -np.pi\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega*4/np.pi,np.abs(X_dtft),ls='--',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*4/np.pi,np.abs(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*4/np.pi,np.abs(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega*4/np.pi,X_dtft_ph,ls='--',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*4/np.pi,np.angle(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*4/np.pi,np.angle(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DTFT magnitude/phase -2pi <= Omega <= 0\n",
+ "Omega = np.arange(-2*np.pi,1/1000,1/1000)\n",
+ "\n",
+ "X_dtft = A*diric(Omega,5)*5\n",
+ "Y_dtft = X_dtft/2*np.exp(-2j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "X_dtft_ph = np.angle(X_dtft)\n",
+ "# exchange pi to -pi for point reflection (DTFT phase)\n",
+ "i = np.where(Omega <= -np.pi,1,0)\n",
+ "j = np.where(X_dtft_ph == np.pi,1,0)\n",
+ "i = np.logical_and(i,j)\n",
+ "i, = np.where(i == True)\n",
+ "X_dtft_ph[i] = -np.pi\n",
+ "\n",
+ "ax1.plot(Omega*4/np.pi,np.abs(X_dtft),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*4/np.pi,np.abs(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*4/np.pi,np.abs(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(Omega*4/np.pi,X_dtft_ph,ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*4/np.pi,np.angle(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*4/np.pi,np.angle(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "#plot DFT period 1\n",
+ "ax1.plot(k,np.abs(X),ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\left|{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\left|{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\left|{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "ax4.plot(k,X_ph,ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "##########################################\n",
+ "# plot DFT magnitude/phase period -1,2 (first element)\n",
+ "mu = np.append(k-8,k[0]+8)\n",
+ "X2 = np.append(X,X[0])\n",
+ "Y2 = np.append(Y,Y[0])\n",
+ "Z2 = np.append(Z,Z[0])\n",
+ "X2_ph = np.append(X_ph,X_ph[0])\n",
+ "\n",
+ "ax1.plot(mu,np.abs(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax2.plot(mu,np.abs(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax3.plot(mu,np.abs(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "ax4.plot(mu,X2_ph,ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax5.plot(mu,np.angle(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax6.plot(mu,np.angle(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "\n",
+ "#####################################################################\n",
+ "#axis settings\n",
+ "\n",
+ "xticks = np.arange(-8,8+1,4)\n",
+ "xlabels = ['$-8$','$-4$','$0$','$+4$','$+8$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-k.size,k.size)\n",
+ "ax2.set_xlim(-k.size,k.size)\n",
+ "ax3.set_xlim(-k.size,k.size)\n",
+ "ax4.set_xlim(-k.size,k.size)\n",
+ "ax5.set_xlim(-k.size,k.size)\n",
+ "ax6.set_xlim(-k.size,k.size)\n",
+ "\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,5*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$','$4A$','$5A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,5*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$',r'$2A$',r'$\\faktor{5A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,25*A**2/2+5*A**2/2,5*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{5A^2}{2}$','$5A^2$',r'$\\faktor{15A^2}{2}$','$10A^2$',r'$\\faktor{25A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DFT_rect.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ca43b7f0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "T = 2.5\n",
+ "Th = T/2\n",
+ "A = 1.5\n",
+ "color1 = 'black'\n",
+ "color2 = 'C0'\n",
+ "color3 = 'C2'\n",
+ "color4 = 'C3'\n",
+ "color5 = 'C4'\n",
+ "\n",
+ "fig = plt.figure(figsize=(11,9))\n",
+ "\n",
+ "ax = fig.add_subplot(311)\n",
+ "\n",
+ "\n",
+ "# time domain\n",
+ "k = np.arange(0,12,dtype=float)\n",
+ "x = np.zeros_like(k)\n",
+ "y = np.zeros_like(k)\n",
+ "\n",
+ "np.put(x,0,A)\n",
+ "np.put(x,1,2*A/3)\n",
+ "np.put(x,2,A/3)\n",
+ "np.put(x,11,2*A/3)\n",
+ "np.put(x,10,A/3)\n",
+ "\n",
+ "\n",
+ "np.put(y,1,A/6)\n",
+ "np.put(y,2,A/3)\n",
+ "np.put(y,3,A/2)\n",
+ "np.put(y,4,A/3)\n",
+ "np.put(y,5,A/6)\n",
+ "\n",
+ "z = np.real(np.fft.ifft(np.fft.fft(x)*np.fft.fft(y)))\n",
+ "\n",
+ "#plot dashed line period 1\n",
+ "k2 = np.append(k,k[0]+12)\n",
+ "x2 = np.append(x,x[0])\n",
+ "y2 = np.append(y,y[0])\n",
+ "z2 = np.append(z,z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls='--',color=color1,\n",
+ " marker='o',mfc=color1,mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls='--',color=color3,\n",
+ " marker='o',mfc=color2,mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls='--',color=color3,\n",
+ " marker='o',mfc=color3,mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot period 2, 3 (first element)\n",
+ "k2 = np.append(np.append(k-24,k-12),k[0])\n",
+ "x2 = np.append(np.append(x,x),x[0])\n",
+ "y2 = np.append(np.append(y,y),y[0])\n",
+ "z2 = np.append(np.append(z,z),z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls=':',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls=':',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "#plot period -2 and -1\n",
+ "\n",
+ "k2 = np.append(k+12,k[0]+24)\n",
+ "x2 = np.append(x,x[0])\n",
+ "y2 = np.append(y,y[0])\n",
+ "z2 = np.append(z,z[0])\n",
+ "\n",
+ "ax.plot(k2,x2,ls=':',color=color1,\n",
+ " marker='o',mfc='white',mec=color1,clip_on=False)\n",
+ "ax.plot(k2,y2,ls=':',color=color2,\n",
+ " marker='o',mfc='white',mec=color2,clip_on=False)\n",
+ "ax.plot(k2,z2,ls=':',color=color3,\n",
+ " marker='o',mfc='white',mec=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "#plot period 1\n",
+ "ax.plot(k,x,label='$x[k]$',color=color1,\n",
+ " mfc=color1,mec=color1,ls='--',marker='o',clip_on=False)\n",
+ "ax.plot(k,y,label=r'$y[k]=\\frac{1}{2} x[k-3]$',color=color2,\n",
+ " mfc=color2,mec=color2,ls='--',marker='o',clip_on=False)\n",
+ "ax.plot(k,z,label=r'$z[k]=x[k]\\circledast_{12} y[k]$',color=color3,\n",
+ " mfc=color3,mec=color3,ls='--',marker='o',clip_on=False)\n",
+ "ax.legend(loc='upper right')\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "# axis settings\n",
+ "ax.set_xlim(-24,24)\n",
+ "ax.set_xticks(np.arange(-24,24+3,3))\n",
+ "ax.set_xlabel('$k$')\n",
+ "labels = []\n",
+ "for i in np.arange(-24,24+3,3):\n",
+ " labels += ['$'+str(i)+'$']\n",
+ "ax.set_xticklabels(labels)\n",
+ "\n",
+ "ax.set_ylim(0,19/18*A**2)\n",
+ "ax.set_yticks([0,A/2,A,19/18*A**2])\n",
+ "ax.set_yticklabels(['$0$',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{19A^2}{18}$'])\n",
+ "ax.set_yticks([0,19/18*A**2])\n",
+ "ax.set_title(r'$x[k]=\\mathrm{tri}_3[k\\bmod 12]$')\n",
+ "ax.grid(True)\n",
+ "\n",
+ "# frequency domain\n",
+ "X = np.fft.fft(x)\n",
+ "Y = np.fft.fft(y)\n",
+ "Z = X*Y\n",
+ "\n",
+ "\n",
+ "\n",
+ "ax1 = fig.add_subplot(334)\n",
+ "ax2 = fig.add_subplot(335)\n",
+ "ax3 = fig.add_subplot(336)\n",
+ "ax4 = fig.add_subplot(337)\n",
+ "ax5 = fig.add_subplot(338)\n",
+ "ax6 = fig.add_subplot(339)\n",
+ "\n",
+ "ax1.set_xlabel('$\\mu$')\n",
+ "ax2.set_xlabel('$\\mu$')\n",
+ "ax3.set_xlabel('$\\mu$')\n",
+ "ax4.set_xlabel('$\\mu$')\n",
+ "ax5.set_xlabel('$\\mu$')\n",
+ "ax6.set_xlabel('$\\mu$')\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "#plot DFT magnitude period 1\n",
+ "ax1.plot(k,np.abs(X),ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\left|{X}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax2.plot(k,np.abs(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\left|{Y}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "ax3.plot(k,np.abs(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\left|{Z}\\left[\\mu\\right]\\right|$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DFT phase period 1\n",
+ "ax4.plot(k,np.angle(X),ls='',marker='o',mfc=color1,mec=color1,\n",
+ " label=r'$\\varphi\\left({X}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax5.plot(k,np.angle(Y),ls='',marker='o',mfc=color2,mec=color2,\n",
+ " label=r'$\\varphi\\left({Y}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "ax6.plot(k,np.angle(Z),ls='',marker='o',mfc=color3,mec=color3,\n",
+ " label=r'$\\varphi\\left({Z}\\left[\\mu\\right]\\right)$',\n",
+ " clip_on=False)\n",
+ "\n",
+ "mu = np.append(k-12,k[0]+12)\n",
+ "X2 = np.append(X,X[0])\n",
+ "Y2 = np.append(Y,Y[0])\n",
+ "Z2 = np.append(Z,Z[0])\n",
+ "\n",
+ "\"\"\"#plot DFT magnitude period -1, 2 (first element)\n",
+ "ax1.plot(mu,np.abs(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax2.plot(mu,np.abs(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax3.plot(mu,np.abs(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "#plot DFT phase period -1, 2 (first element)\n",
+ "ax4.plot(mu,np.angle(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax5.plot(mu,np.angle(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax6.plot(mu,np.angle(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\"\"\"\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "#plot DTFT magnitude/phase 0 <= Omega <= 2 pi\n",
+ "Omega = np.arange(0,2*np.pi+1/1000,1/1000)\n",
+ "\n",
+ "X_dtft = A*diric(Omega,3)**2*3\n",
+ "Y_dtft = X_dtft/2*np.exp(-3j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "# plot DTFT magnitude\n",
+ "ax1.plot(Omega*6/np.pi,np.abs(X_dtft),ls='--',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*6/np.pi,np.abs(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*6/np.pi,np.abs(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "# plot DTFT phase\n",
+ "ax4.plot(Omega*6/np.pi,np.angle(X_dtft),ls='--',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*6/np.pi,np.angle(Y_dtft),ls='--',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*6/np.pi,np.angle(Z_dtft),ls='--',color=color3,clip_on=False)\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DTFT magnitude/phase -2pi <= Omega <= 0\n",
+ "Omega = np.arange(-2*np.pi,1/1000,1/1000)\n",
+ "\n",
+ "X_dtft = A*diric(Omega,3)**2*3\n",
+ "Y_dtft = X_dtft/2*np.exp(-3j*Omega)\n",
+ "Z_dtft = X_dtft*Y_dtft\n",
+ "\n",
+ "ax1.plot(Omega*6/np.pi,np.abs(X_dtft),ls=':',color=color1,clip_on=False)\n",
+ "ax2.plot(Omega*6/np.pi,np.abs(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax3.plot(Omega*6/np.pi,np.abs(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "ax4.plot(Omega*6/np.pi,np.angle(X_dtft),ls=':',color=color1,clip_on=False)\n",
+ "ax5.plot(Omega*6/np.pi,np.angle(Y_dtft),ls=':',color=color2,clip_on=False)\n",
+ "ax6.plot(Omega*6/np.pi,np.angle(Z_dtft),ls=':',color=color3,clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "\n",
+ "#plot DFT magnitude period -1, 2 (first element)\n",
+ "ax1.plot(mu,np.abs(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax2.plot(mu,np.abs(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax3.plot(mu,np.abs(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "\n",
+ "#plot DFT phase period -1, 2 (first element)\n",
+ "ax4.plot(mu,np.angle(X2),ls='',marker='o',mec=color1,mfc='white',clip_on=False)\n",
+ "ax5.plot(mu,np.angle(Y2),ls='',marker='o',mec=color2,mfc='white',clip_on=False)\n",
+ "ax6.plot(mu,np.angle(Z2),ls='',marker='o',mec=color3,mfc='white',clip_on=False)\n",
+ "\n",
+ "\n",
+ "##########################################\n",
+ "\n",
+ "# axis settings\n",
+ "xticks = np.arange(-12,12+1,4)\n",
+ "xlabels = ['$-12$','$-8$','$-4$','$0$','$+4$','$+8$','$+12$']\n",
+ "\n",
+ "yticks = np.arange(-np.pi,np.pi+np.pi/2,np.pi/2)\n",
+ "ylabels = ['$-\\pi$',r'$-\\faktor{\\pi}{2}$','$0$',r'$+\\faktor{\\pi}{2}$',r'$+\\pi$']\n",
+ "\n",
+ "ax1.set_xlim(-k.size,k.size)\n",
+ "ax2.set_xlim(-k.size,k.size)\n",
+ "ax3.set_xlim(-k.size,k.size)\n",
+ "ax4.set_xlim(-k.size,k.size)\n",
+ "ax5.set_xlim(-k.size,k.size)\n",
+ "ax6.set_xlim(-k.size,k.size)\n",
+ "\n",
+ "\n",
+ "ax1.set_xticks(xticks)\n",
+ "ax2.set_xticks(xticks)\n",
+ "ax3.set_xticks(xticks)\n",
+ "ax4.set_xticks(xticks)\n",
+ "ax5.set_xticks(xticks)\n",
+ "ax6.set_xticks(xticks)\n",
+ "\n",
+ "ax1.set_xticklabels(xlabels)\n",
+ "ax2.set_xticklabels(xlabels)\n",
+ "ax3.set_xticklabels(xlabels)\n",
+ "ax4.set_xticklabels(xlabels)\n",
+ "ax5.set_xticklabels(xlabels)\n",
+ "ax6.set_xticklabels(xlabels)\n",
+ "\n",
+ "\n",
+ "ax1.set_ylim(0,np.amax(np.abs(X)))\n",
+ "ax2.set_ylim(0,np.amax(np.abs(Y)))\n",
+ "ax3.set_ylim(0,np.amax(np.abs(Z)))\n",
+ "\n",
+ "ax1.set_yticks(np.arange(0,3*A+A,A))\n",
+ "ax1.set_yticklabels(['$0$','$A$','$2A$','$3A$'])\n",
+ "\n",
+ "ax2.set_yticks(np.arange(0,3*A/2+A/2,A/2))\n",
+ "ax2.set_yticklabels(['0',r'$\\faktor{A}{2}$','$A$',r'$\\faktor{3A}{2}$'])\n",
+ "\n",
+ "ax3.set_yticks(np.arange(0,9*A**2/2+3*A**2/2,3*A**2/2))\n",
+ "ax3.set_yticklabels(['$0$',r'$\\faktor{3A^2}{2}$','$3A^2$',r'$\\faktor{9A^2}{2}$'])\n",
+ "\n",
+ "ax4.set_ylim(-np.pi,+np.pi)\n",
+ "ax5.set_ylim(-np.pi,+np.pi)\n",
+ "ax6.set_ylim(-np.pi,+np.pi)\n",
+ "\n",
+ "ax4.set_yticks(yticks)\n",
+ "ax5.set_yticks(yticks)\n",
+ "ax6.set_yticks(yticks)\n",
+ "\n",
+ "ax4.set_yticklabels(ylabels)\n",
+ "ax5.set_yticklabels(ylabels)\n",
+ "ax6.set_yticklabels(ylabels)\n",
+ "\n",
+ "\n",
+ "ax1.legend(fontsize=11,loc='center right')\n",
+ "ax2.legend(fontsize=11,loc='center right')\n",
+ "ax3.legend(fontsize=11,loc='center right')\n",
+ "ax4.legend(fontsize=11,loc='upper right')\n",
+ "ax5.legend(fontsize=11,loc='upper right')\n",
+ "ax6.legend(fontsize=11,loc='upper right')\n",
+ "\n",
+ "ax1.grid(True)\n",
+ "ax2.grid(True)\n",
+ "ax3.grid(True)\n",
+ "ax4.grid(True)\n",
+ "ax5.grid(True)\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('DFT_tri.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b798e8bf",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sigma_0 = Symbol('\\sigma_0',positive=True)\n",
+ "s = Symbol('s')\n",
+ "t = Symbol('t')\n",
+ "A = Symbol('A')\n",
+ "omega = Symbol('\\omega')\n",
+ "omega_0 = Symbol('\\omega_0',positive=True)\n",
+ "F = A/(s+sigma_0)\n",
+ "f = transforms.inverse_laplace_transform(F,s,t)\n",
+ "display(Math(latex(f)))\n",
+ "F = A*(s-sigma_0)/(s+sigma_0)\n",
+ "F = apart(F,s)\n",
+ "f = transforms.inverse_laplace_transform(F,s,t)\n",
+ "display(Math(latex(f)))\n",
+ "F = (s+sigma_0/4)/(s-(-sigma_0/4+I*omega_0))/(s-(-sigma_0/4-I*omega_0))\n",
+ "F = apart(F,s)\n",
+ "f = transforms.inverse_laplace_transform(F,s,t)\n",
+ "display(Math(latex(f)))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "27bc8fad",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [],
+ "source": [
+ "fig, ((ax1,ax2),(ax3,ax4),(ax5,ax6)) = plt.subplots(ncols=2,nrows=3,gridspec_kw=dict(width_ratios=[1,2.25]),figsize=(11,9))\n",
+ "\n",
+ "################################################################################\n",
+ "# zeros, poles, gains\n",
+ "\n",
+ "omega_0 = 1\n",
+ "sigma_0 = 1\n",
+ "A=1\n",
+ "s_infty0=-sigma_0+0j*omega_0\n",
+ "s_zero0=sigma_0+0j*omega_0\n",
+ "s_zero1=-sigma_0/4\n",
+ "s_infty1=-sigma_0/4+1j*omega_0\n",
+ "s_infty2=-sigma_0/4-1j*omega_0\n",
+ "s = np.arange(np.real(s_infty0),2+1/1000,1/1000)\n",
+ "s2 = np.arange(np.real(s_infty1),2+1/1000,1/1000)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# s-plane\n",
+ "\n",
+ "ax1.fill_between(s,\n",
+ " np.zeros_like(s)-2,\n",
+ " np.zeros_like(s)+2,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{s\\}$',\n",
+ " alpha=0.5,\n",
+ " )\n",
+ "ax1.set_xlabel(r'$\\mathrm{Re}\\{s\\}$')\n",
+ "ax1.set_ylabel(r'$\\mathrm{Im}\\{s\\}$')\n",
+ "ax1.scatter(np.real(s_infty0),np.imag(s_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "ax1.set_xlim(-2*sigma_0,2*sigma_0)\n",
+ "ax1.set_ylim(-2*omega_0,2*omega_0)\n",
+ "ax1.set_xticks(np.arange(-2,2+1,1))\n",
+ "ax1.set_yticks(np.arange(-2,2+1,1))\n",
+ "ax1.set_xticklabels([r'$-2\\sigma_0$',r'$-\\sigma_0$','$0$',r'$+\\sigma_0$',r'$+2\\sigma_0$'])\n",
+ "ax1.set_yticklabels([r'$-2\\omega_0$',r'$-\\omega_0$',r'$0$',r'$+\\omega_0$',r'$+2\\omega_0$'])\n",
+ "ax1.text(1,-1.5,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax1.grid(True)\n",
+ "ax1.annotate(r'$s_{\\infty,0}$',\n",
+ " (np.real(s_infty0),np.imag(s_infty0)),\n",
+ " (np.real(s_infty0),np.imag(s_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax1.set_box_aspect(1)\n",
+ "ax1.legend(edgecolor='black')\n",
+ "ax1.set_title(r'$H(s)=A\\frac{1}{s+\\sigma_0}$',pad=10)\n",
+ "\n",
+ "# time-domain\n",
+ "\n",
+ "system = signal.lti([],[s_infty0],A)\n",
+ "t = np.arange(0,7*np.log(2)/sigma_0,1/1000)\n",
+ "t, impulse = signal.lti.impulse(system,T=t)\n",
+ "ax2.plot(t,impulse,clip_on=False)\n",
+ "ax2.set_ylim(0,A)\n",
+ "ax2.set_xlim(1,-np.log(2**7)/np.real(s_infty0))\n",
+ "ax2.set_yticks([0,A/8,A/4,A/2,A])\n",
+ "ax2.set_yticklabels(['$0$',r'$\\faktor{A}{8}$',r'$\\faktor{A}{4}$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "ax2.set_xticks(np.arange(0,-np.log(2**8)/np.real(s_infty0),-np.log(2)/np.real(s_infty0)))\n",
+ "xticklabels=['$0$',r'$\\frac{\\ln(2)}{\\sigma_0}$']\n",
+ "for i in range(2,8):\n",
+ " xticklabels += [r'$\\frac{%d\\ln(2)}{\\sigma_0}$'%(i)]\n",
+ "ax2.set_xticklabels(xticklabels)\n",
+ "ax2.grid(True)\n",
+ "ax2.set_title(r'$h(t)=A\\mathrm{e}^{-\\sigma_0t}\\epsilon(t)$',pad=10)\n",
+ "ax2.set_xlabel('$t$')\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "ax3.fill_between(s,\n",
+ " np.zeros_like(s)-2,\n",
+ " np.zeros_like(s)+2,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{s\\}$',\n",
+ " alpha=0.5,\n",
+ " )\n",
+ "ax3.set_xlabel(r'$\\mathrm{Re}\\{s\\}$')\n",
+ "ax3.set_ylabel(r'$\\mathrm{Im}\\{s\\}$')\n",
+ "ax3.scatter(np.real(s_infty0),np.imag(s_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "\n",
+ "ax3.scatter(np.real(s_zero0),np.imag(s_zero0),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc='none'\n",
+ " )\n",
+ "ax3.set_xlim(-2*sigma_0,2*sigma_0)\n",
+ "ax3.set_ylim(-2*omega_0,2*omega_0)\n",
+ "ax3.set_xticks(np.arange(-2,2+1,1))\n",
+ "ax3.set_yticks(np.arange(-2,2+1,1))\n",
+ "ax3.set_xticklabels([r'$-2\\sigma_0$',r'$-\\sigma_0$','$0$',r'$+\\sigma_0$',r'$+2\\sigma_0$'])\n",
+ "ax3.set_yticklabels([r'$-2\\omega_0$',r'$-\\omega_0$',r'$0$',r'$+\\omega_0$',r'$+2\\omega_0$'])\n",
+ "ax3.text(1,-1.5,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='round',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax3.grid(True)\n",
+ "ax3.annotate(r'$s_{\\infty,0}$',\n",
+ " (np.real(s_infty0),np.imag(s_infty0)),\n",
+ " (np.real(s_infty0),np.imag(s_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "\n",
+ "ax3.annotate(r'$s_{0,0}$',\n",
+ " (np.real(s_zero0),np.imag(s_zero0)),\n",
+ " (np.real(s_zero0),np.imag(s_zero0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax3.set_box_aspect(1)\n",
+ "ax3.legend(edgecolor='black')\n",
+ "\n",
+ "ax3.set_title(r'$H(s)=A\\frac{s-\\sigma_0}{s+\\sigma_0}$',pad=10)\n",
+ "\n",
+ "# time-domain\n",
+ "\n",
+ "system = signal.lti([s_zero0],[s_infty0],A)\n",
+ "t, impulse = signal.lti.impulse(system,T=t)\n",
+ "ax4.plot(t,impulse,clip_on=False)\n",
+ "ax4.annotate(text='',xy=(0,0),xytext=(0,A),\n",
+ " arrowprops=dict(arrowstyle='<-',\n",
+ " connectionstyle='arc3',\n",
+ " shrinkA=0,shrinkB=0,\n",
+ " ec='C0',fc='C0',\n",
+ " lw=1.5,\n",
+ " clip_on=False))\n",
+ "ax4.set_yticks([-2*A,-A,-A/2,-A/4,0,A])\n",
+ "ax4.set_yticklabels(['$-2A\\sigma_0$','$-A\\sigma_0$',r'$-\\faktor{A\\sigma_0}{2}$',r'$-\\faktor{A\\sigma_0}{4}$','$0$','$A$'])\n",
+ "ax4.set_ylim(-2*A*sigma_0,1)\n",
+ "ax4.set_xlim(1,-np.log(2**7)/np.real(s_infty0))\n",
+ "ax4.set_xticks(np.arange(0,-np.log(2**8)/np.real(s_infty0),-np.log(2)/np.real(s_infty0)))\n",
+ "ax4.set_xticklabels(xticklabels)\n",
+ "ax4.grid(True)\n",
+ "ax4.set_title(r'$h(t)=A\\delta(t)-2A\\sigma_0\\e^{-\\sigma_0t}\\epsilon(t)$',pad=10)\n",
+ "ax4.set_xlabel('$t$')\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# s-plane\n",
+ "\n",
+ "ax5.fill_between(s2,\n",
+ " np.zeros_like(s2)-2,\n",
+ " np.zeros_like(s2)+2,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{s\\}$',\n",
+ " alpha=0.5,\n",
+ " )\n",
+ "ax5.set_xlabel(r'$\\mathrm{Re}\\{s\\}$')\n",
+ "ax5.set_ylabel(r'$\\mathrm{Im}\\{s\\}$')\n",
+ "ax5.scatter(np.real(s_infty1),np.imag(s_infty1),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "\n",
+ "ax5.scatter(np.real(s_infty2),np.imag(s_infty2),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0'\n",
+ " )\n",
+ "ax5.scatter(np.real(s_zero1),np.imag(s_zero1),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc='none'\n",
+ " )\n",
+ "ax5.set_xlim(-2*sigma_0,2*sigma_0)\n",
+ "ax5.set_ylim(-2*omega_0,2*omega_0)\n",
+ "ax5.set_xticks(np.arange(-2,2+1,1))\n",
+ "ax5.set_yticks(np.arange(-2,2+1,1))\n",
+ "ax5.set_xticklabels([r'$-2\\sigma_0$',r'$-\\sigma_0$','$0$',r'$+\\sigma_0$',r'$+2\\sigma_0$'])\n",
+ "ax5.set_yticklabels([r'$-2\\omega_0$',r'$-\\omega_0$',r'$0$',r'$+\\omega_0$',r'$+2\\omega_0$'])\n",
+ "ax5.text(1,-1.5,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='round',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax5.grid(True)\n",
+ "ax5.annotate(r'$s_{\\infty,1}$',\n",
+ " (np.real(s_infty1),np.imag(s_infty1)),\n",
+ " (np.real(s_infty1),np.imag(s_infty1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax5.annotate(r'$s_{\\infty,2}$',\n",
+ " (np.real(s_infty2),np.imag(s_infty2)),\n",
+ " (np.real(s_infty2),np.imag(s_infty2)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax5.annotate(r'$s_{0,1}$',\n",
+ " (np.real(s_zero1),np.imag(s_zero1)),\n",
+ " (np.real(s_zero1),np.imag(s_zero1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center')\n",
+ "ax5.set_box_aspect(1)\n",
+ "ax5.legend(edgecolor='black')\n",
+ "ax5.set_title(r'$H(s)=A\\frac{s+\\faktor{\\sigma_0}{4}}{(s-(-\\faktor{\\sigma_0}{4}+\\im\\omega_0))(s-(-\\faktor{\\sigma_0}{4}-\\im\\omega_0))}$',pad=10)\n",
+ "\n",
+ "# time-domain\n",
+ "\n",
+ "system = signal.lti([s_zero1],[s_infty1,s_infty2],A)\n",
+ "t = np.arange(0,28*np.log(2)/sigma_0+1/1000,1/1000)\n",
+ "t, impulse = signal.lti.impulse(system,T=t)\n",
+ "ax6.plot(t,impulse,clip_on=False)\n",
+ "ax6.set_yticks([-A,-A/2,-A/4,0,A/4,A/2,A])\n",
+ "ax6.set_yticklabels(['$-A$',r'$-\\faktor{A}{2}$',r'$-\\faktor{A}{4}$','$0$',r'$+\\faktor{A}{4}$',r'$+\\faktor{A}{2}$','$+A$'])\n",
+ "ax6.set_ylim(-A,A)\n",
+ "ax6.set_xticks(np.arange(0,28*np.log(2)/sigma_0+4*np.log(2)/sigma_0,4*np.log(2)/sigma_0))\n",
+ "xticklabels = [r'$0$']\n",
+ "for i in range(4,28+4,4):\n",
+ " xticklabels += [r'$\\frac{%d\\ln(2)}{\\sigma_0}$'%(i)]\n",
+ "ax6.set_xticklabels(xticklabels)\n",
+ "ax6.set_xlim(0,28*np.log(2)/sigma_0)\n",
+ "ax6.grid(True)\n",
+ "ax6.set_title(r'$h(t)=\\e^{-\\frac{\\sigma_0}{4}t}\\cos\\left(\\omega t\\right)\\epsilon(t)$',pad=20)\n",
+ "ax6.set_xlabel('$t$')\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('laplace.pdf')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "63c3d5e7",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "z = Symbol('z')\n",
+ "r = Symbol('r')\n",
+ "a = Symbol('a')\n",
+ "b = Symbol('b')\n",
+ "phi = Symbol(r'\\varphi')\n",
+ "A = Symbol('A')\n",
+ "Omega_0 = Symbol('Omega_0')\n",
+ "F = (z-2)/(z-Rational(1,2))/z\n",
+ "apart(F,z)*z"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "db252f84",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "fig, ((ax1,ax2),(ax3,ax4),(ax5,ax6)) = plt.subplots(ncols=2,nrows=3,gridspec_kw=dict(width_ratios=[1,2.5]),figsize=(11,9))\n",
+ "\n",
+ "################################################################################\n",
+ "# poles, zeros, gain\n",
+ "A = 1\n",
+ "r = 1/2\n",
+ "Omega_0 = 4*np.log(2)/sigma_0\n",
+ "z_infty0 = r\n",
+ "z_zero0 = 0\n",
+ "#z_zero1 = r+sigma_0\n",
+ "z_zero1 = 1/r\n",
+ "z_zero2 = r*np.cos(Omega_0)\n",
+ "z_infty1 = r*np.exp(1j*Omega_0)\n",
+ "z_infty2 = r*np.exp(-1j*Omega_0)\n",
+ "z = np.arange(-3,3+1/1000,1/1000)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "\n",
+ "ax1.fill_between(z,\n",
+ " np.zeros_like(z)-1.5,\n",
+ " np.zeros_like(z)+1.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax1.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax1.add_patch(circle)\n",
+ "ax1.set_box_aspect(1)\n",
+ "\n",
+ "ax1.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax1.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax1.scatter(np.real(z_infty0),np.imag(z_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax1.annotate(r'$z_{\\infty,0}$',\n",
+ " (np.real(z_infty0),np.imag(z_infty0)),\n",
+ " (np.real(z_infty0),np.imag(z_infty0)-0.25),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "\n",
+ "ax1.scatter(np.real(z_zero0),np.imag(z_zero0),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = 'white',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax1.annotate(r'$z_{0,0}$',\n",
+ " (np.real(z_zero0),np.imag(z_zero0)),\n",
+ " (np.real(z_zero0),np.imag(z_zero0)-0.25),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "ax1.text(0,-0.75,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax1.set_xticks(np.arange(-1,2,1))\n",
+ "ax1.set_yticks(np.arange(-1,2,1))\n",
+ "ax1.set_xlim(-1,1)\n",
+ "ax1.set_ylim(-1,1)\n",
+ "ax1.legend(loc='upper right')\n",
+ "ax1.set_title(r'$H(z)=A\\frac{z}{z-\\faktor{1}{2}}$',pad=20)\n",
+ "ax1.grid(True)\n",
+ "ax1.set_axisbelow(True)\n",
+ "\n",
+ "system = signal.dlti([z_zero0],[z_infty0],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax2.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "impulse2 = z_infty0**k\n",
+ "ax2.plot(k,impulse2,ls=':',color='C0',clip_on=False)\n",
+ "\n",
+ "\n",
+ "ax2.set_xticks(np.arange(0,8))\n",
+ "ax2.set_yticks([0,A/8,A/4,A/2,A])\n",
+ "ax2.set_yticklabels(['$0$',r'$\\faktor{A}{8}$',r'$\\faktor{A}{4}$',r'$\\faktor{A}{2}$','$A$'])\n",
+ "\n",
+ "ax2.set_xlim(0,7)\n",
+ "ax2.set_ylim(0,A)\n",
+ "\n",
+ "ax2.set_xlabel('$k$')\n",
+ "ax2.set_title(r'$h[k]=A\\left(\\frac{1}{2}\\right)^k\\epsilon[k]$',pad=20)\n",
+ "ax2.grid(True)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# z-plane\n",
+ "ax3.fill_between(z,\n",
+ " np.zeros_like(z)-2.5,\n",
+ " np.zeros_like(z)+2.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "ax3.set_box_aspect(1)\n",
+ "\n",
+ "ax3.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax3.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax3.scatter(np.real(z_infty0),np.imag(z_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{\\infty,0}$',\n",
+ " (np.real(z_infty0),np.imag(z_infty0)),\n",
+ " (np.real(z_infty0),np.imag(z_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'right',\n",
+ " \n",
+ " )\n",
+ "\n",
+ "ax3.scatter(np.real(z_zero1),np.imag(z_zero1),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " clip_on=False,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{0,1}$',\n",
+ " (np.real(z_zero1),np.imag(z_zero1)),\n",
+ " (np.real(z_zero1),np.imag(z_zero1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "ax3.text(0,-0.75*2,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax3.set_xticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_yticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_xlim(-2,2)\n",
+ "ax3.set_ylim(-2,2)\n",
+ "ax3.legend(loc='upper right')\n",
+ "ax3.set_title(r'$H(z)=A\\frac{z-2}{z-\\faktor{1}{2}}$',pad=20)\n",
+ "ax3.grid(True)\n",
+ "ax3.set_axisbelow(True)\n",
+ "\n",
+ "# time domain\n",
+ "\n",
+ "system = signal.dlti([z_zero1],[z_infty0],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax4.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "impulse2 = -3*A*(1/2)**k\n",
+ "ax4.plot(k,impulse2,ls=':',color='C0',clip_on=False)\n",
+ "\n",
+ "#ax4.set_xticks(np.arange(0,8))\n",
+ "ax4.set_yticks([-3*A,-3*A/2,-3*A/4,-3*A/8,0,A])\n",
+ "ax4.set_yticklabels(['$-3A$',r'$-\\faktor{3A}{2}$',r'$-\\faktor{3A}{4}$',r'$-\\faktor{3A}{8}$','$0$','$A$'])\n",
+ "\n",
+ "ax4.set_xlim(0,7)\n",
+ "ax4.set_ylim(-3*A,A)\n",
+ "\n",
+ "ax4.set_title(r'$h[k]=4A\\delta[k]-3A\\left(\\frac{1}{2}\\right)^k\\epsilon[k]$',pad=20)\n",
+ "ax4.set_xlabel('$k$')\n",
+ "ax4.grid(True)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "\"\"\"\n",
+ "ax3.fill_between(z,\n",
+ " np.zeros_like(z)-2.5,\n",
+ " np.zeros_like(z)+2.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.add_patch(circle)\n",
+ "ax3.set_box_aspect(1)\n",
+ "\n",
+ "ax3.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax3.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax3.scatter(np.real(z_infty0),np.imag(z_infty0),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{\\infty,0}$',\n",
+ " (np.real(z_infty0),np.imag(z_infty0)),\n",
+ " (np.real(z_infty0),np.imag(z_infty0)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'right',\n",
+ " \n",
+ " )\n",
+ "\n",
+ "ax3.scatter(np.real(z_zero1),np.imag(z_zero1),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax3.annotate(r'$z_{0,1}$',\n",
+ " (np.real(z_zero1),np.imag(z_zero1)),\n",
+ " (np.real(z_zero1),np.imag(z_zero1)-0.5),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " )\n",
+ "ax3.text(0,-0.75*2,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax3.set_xticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_yticks(np.arange(-2,2.5,1))\n",
+ "ax3.set_xlim(-2,2)\n",
+ "ax3.set_ylim(-2,2)\n",
+ "ax3.legend(loc='upper right')\n",
+ "ax3.set_title(r'$H(z)=A\\frac{z-\\left(\\faktor{1}{2}+\\sigma_0\\right)}{z-\\faktor{1}{2}}$',pad=20)\n",
+ "ax3.grid(True)\n",
+ "ax3.set_axisbelow(True)\n",
+ "\n",
+ "system = signal.dlti([z_zero1],[z_infty0],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax4.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "impulse2 = -2*A*sigma_0*(1/2)**k\n",
+ "ax4.plot(k,impulse2,ls=':',color='C0',clip_on=False)\n",
+ "ax4.annotate(text='',xy=(0,0),xytext=(0,A),\n",
+ " arrowprops=dict(arrowstyle='<-',\n",
+ " connectionstyle='arc3',\n",
+ " shrinkA=0,shrinkB=0,\n",
+ " ec='C0',fc='C0',\n",
+ " lw=1.5,\n",
+ " ls=':',\n",
+ " clip_on=False))\n",
+ "\n",
+ "#ax4.set_xticks(np.arange(0,8))\n",
+ "ax4.set_yticks([-2*A*sigma_0,-A*sigma_0,-A/2*sigma_0,-A/4*sigma_0,0,A])\n",
+ "ax4.set_yticklabels(['$-2A\\sigma_0$','$-A\\sigma_0$',r'$-\\faktor{A\\sigma_0}{2}$',r'$-\\faktor{A\\sigma_0}{4}$','$0$','$A$'])\n",
+ "\n",
+ "ax4.set_xlim(0,7)\n",
+ "ax4.set_ylim(-2*A*sigma_0,A)\n",
+ "\n",
+ "ax4.set_title(r'$h[k]=A\\delta[k]-2A\\sigma_0\\left(\\frac{1}{2}\\right)\\epsilon[k]$',pad=20)\n",
+ "ax4.set_xlabel('$k$')\n",
+ "ax4.grid(True)\n",
+ "\"\"\"\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "# z-plane\n",
+ "\n",
+ "ax5.fill_between(z,\n",
+ " np.zeros_like(z)-2.5,\n",
+ " np.zeros_like(z)+2.5,\n",
+ " color='C2',\n",
+ " clip_on=True,\n",
+ " label=r'$\\mathrm{ROC}\\{z\\}$',\n",
+ " alpha=0.5,\n",
+ " zorder=0,\n",
+ " )\n",
+ "\n",
+ "circle = Circle((0,0),\n",
+ " np.abs(z_infty0),\n",
+ " fc='white',\n",
+ " ec='white',\n",
+ " zorder=0,\n",
+ " lw=0,\n",
+ " )\n",
+ "ax5.add_patch(circle)\n",
+ "fc = colors.to_rgba(c='C2',alpha=0)\n",
+ "circle = Circle((0,0),\n",
+ " 1,\n",
+ " ec='black',\n",
+ " fc=fc,\n",
+ " lw=2,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.add_patch(circle)\n",
+ "ax5.set_box_aspect(1)\n",
+ "\n",
+ "ax5.set_xlabel(r'$\\mathrm{Re}\\{z\\}$')\n",
+ "ax5.set_ylabel(r'$\\mathrm{Im}\\{z\\}$')\n",
+ "ax5.scatter(np.real(z_infty1),np.imag(z_infty1),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{\\infty,1}$',\n",
+ " (np.real(z_infty1),np.imag(z_infty1)),\n",
+ " (np.real(z_infty1),np.imag(z_infty1)+0.3),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " va = 'center',\n",
+ " \n",
+ " )\n",
+ "ax5.scatter(np.real(z_infty2),np.imag(z_infty2),\n",
+ " s=75,\n",
+ " marker='x',\n",
+ " color='C0',\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{\\infty,2}$',\n",
+ " (np.real(z_infty2),np.imag(z_infty2)),\n",
+ " (np.real(z_infty2),np.imag(z_infty2)-0.3),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " \n",
+ " )\n",
+ "ax5.scatter(np.real(z_zero2),np.imag(z_zero2),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{0,1}$',\n",
+ " (np.real(z_zero2),np.imag(z_zero2)),\n",
+ " (np.real(z_zero2)-0.1,np.imag(z_zero2)),\n",
+ " size='x-large',\n",
+ " ha = 'right',\n",
+ " va = 'center',\n",
+ " )\n",
+ "ax5.scatter(np.real(z_zero0),np.imag(z_zero0),\n",
+ " s=75,\n",
+ " marker='o',\n",
+ " ec='C0',\n",
+ " fc = fc,\n",
+ " zorder=1,\n",
+ " )\n",
+ "ax5.annotate(r'$z_{0,0}$',\n",
+ " (np.real(z_zero0),np.imag(z_zero0)),\n",
+ " (np.real(z_zero0),np.imag(z_zero0)-0.25),\n",
+ " size='x-large',\n",
+ " ha = 'center',\n",
+ " va = 'center',\n",
+ " )\n",
+ "ax5.text(0,-0.75,\n",
+ " s='$g=A$',\n",
+ " bbox=dict(boxstyle='square',ec='black',fc='white'),\n",
+ " ha='center')\n",
+ "ax5.set_xticks(np.arange(-1,1+1,1))\n",
+ "ax5.set_yticks(np.arange(-1,1+1,1))\n",
+ "ax5.set_xlim(-1,1)\n",
+ "ax5.set_ylim(-1,1)\n",
+ "ax5.legend(loc='upper right')\n",
+ "ax5.set_title(r'$H(z)=A\\frac{z\\left(z-\\faktor{1}{2}\\cos(\\Omega_0\\right)}{\\left(z-\\faktor{1}{2}\\e^{+\\im\\Omega_0}\\right)\\left(z-\\faktor{1}{2}\\e^{-\\im\\Omega_0}\\right)}$',pad=20)\n",
+ "ax5.grid(True)\n",
+ "ax5.set_axisbelow(True)\n",
+ "\n",
+ "# time domain\n",
+ "\n",
+ "system = signal.dlti([z_zero0,z_zero2],[z_infty1,z_infty2],A)\n",
+ "k, impulse = signal.dimpulse(system,n=8)\n",
+ "impulse = impulse[0]\n",
+ "\n",
+ "ax6.plot(k,impulse,ls='',marker='o',mfc='C0',mec='C0',clip_on=False)\n",
+ "\n",
+ "k = np.arange(0,7+1/1000,1/1000)\n",
+ "h = r**k*np.cos(Omega_0*k)\n",
+ "ax6.plot(k,h,ls=':',color='C0',clip_on=False)\n",
+ "ax6.set_xticks(np.arange(8))\n",
+ "ax6.set_yticks([-A,-A/2,-A/4,0,A/4,A/2,A])\n",
+ "ax6.set_yticklabels(['$-A$',r'$- \\faktor{A}{2}$',r'$-\\faktor{A}{4}$','$0$',r'$+\\faktor{A}{4}$',r'$+\\faktor{A}{2}$','$+A$'])\n",
+ "\n",
+ "ax6.set_xlim(0,7)\n",
+ "ax6.set_ylim(-A,A)\n",
+ "ax6.set_title(r'$h[k]=\\left(\\frac{1}{2}\\right)^k\\cos[\\Omega_0 k]\\epsilon[k]$',pad=20)\n",
+ "ax6.set_xlabel('$k$')\n",
+ "ax6.grid(True)\n",
+ "\n",
+ "################################################################################\n",
+ "\n",
+ "fig.tight_layout()\n",
+ "fig.savefig('zTrafo.pdf')"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.7"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/signals-and-systems-cheatsheet.tex b/signals-and-systems-cheatsheet.tex
new file mode 100644
index 0000000..00fd15f
--- /dev/null
+++ b/signals-and-systems-cheatsheet.tex
@@ -0,0 +1,334 @@
+\documentclass[landscape,columns=3]{cheatsheet} %https://ctan.org/pkg/cheatsheet?lang=en
+\geometry{paper=a3paper}
+\hypersetup{colorlinks = false, allbordercolors = white}
+\title{Signals and Systems Cheat Sheet\\
+\tiny{\url{https://github.com/spatialaudio/signals-and-systems-cheatsheet}}}
+\author{
+Robert Hauser,
+\href{https://orcid.org/0000-0002-3010-0294}{Frank Schultz},
+University of Rostock
+}
+\date{\today}
+\usepackage{graphicx}
+\usepackage{fouriernc}
+\usepackage{amsmath}
+\usepackage{amsfonts}
+\usepackage{amssymb}
+\usepackage{amsbsy}
+\usepackage{bm}
+\usepackage{trfsigns}
+\usepackage{pgfplots}
+\usepackage{caption}
+\usepackage{trfsigns}
+\usetikzlibrary{arrows.meta}
+
+%macros
+\usepackage{sig_sys_macros}
+
+%constants
+\def\T{2.5}
+\def\Th{1.25}
+\def\A{1.5}
+
+%small commands
+\newcommand{\sinc}{\mathrm{sinc}}
+\newcommand{\rect}{\mathrm{rect}}
+\begin{document}
+%\maketitle
+
+\section{Continuous-Time Domain}
+%
+\begin{itemize}
+\setlength\itemsep{-0.5em}
+\item time $t$ in s, (physical) frequency $f$ in Hz
+%
+\item angular frequency $\omega = 2 \pi f$ in rad/s
+%
+\item cycle duration $T_0$ in s
+%
+\item fundamental oscillation $f_0 = \frac{1}{T_0}$ in Hz
+$\rightarrow \omega_0 = 2 \pi f_0 = \frac{2\pi}{T_0}$ in rad/s
+%
+\end{itemize}
+
+%\includegraphics[width=2.925in]{test.png}
+
+\subsection{Fundamental Signals}
+
+\subsection{Laplace Transform}
+%
+\begin{align*}
+X(s) = \int\limits_{-\infty}^{+\infty} x(t) \, \e^{-s t}\,\mathrm{d}t
+\qquad
+x(t) = \frac{1}{2\pi\im}\lim_{\omega\to\infty}\int\limits_{s=\sigma-\im\omega}^{\sigma+\im\omega} X(s) \,\e^{+s t}\,\mathrm{d}s
+\end{align*}
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{laplace}
+\end{minipage}
+
+
+
+\columnbreak
+\subsection{Fourier Series (FS)}
+%
+%
+%Rechteckschwingung
+%
+\begin{itemize}
+\setlength\itemsep{-0.5em}
+\item continuous-time, periodic signal $x(t)$
+%
+\item discrete-frequency, non-periodic spectrum $\tilde{X}[\mu]$
+%
+\item $t\in\mathbb{R}$ and $\mu,\nu\in\mathbb{Z}$
+%
+\item $T_0$-periodicity: $x(t)=x(t+\nu T_0)$ with $\omega_0 = \frac{2\pi}{T_0}$
+%
+\end{itemize}
+%
+\begin{align*}
+\tilde{X}[\mu] = \int\limits_{0}^{T_0} x(t) \, \e^{-\im \omega_0 \mu t}\,\mathrm{d}t
+\qquad
+x(t) = \frac{1}{T_0}\sum\limits_{\mu=-\infty}^{+\infty} \tilde{X}[\mu] \,\e^{+\im \omega_0 \mu t}
+\end{align*}
+
+
+\begin{minipage}{\columnwidth}
+\includegraphics[width=\columnwidth,keepaspectratio]{fourier_series_rect}
+%\captionof{figure}{zeitlicher Verlauf sowie Fourierkoeffizienten der Rechteckschwingung, ihrer Verschiebung sowie deren Faltung}
+\end{minipage}
+%
+%
+\begin{minipage}{\columnwidth}
+\includegraphics[width=\columnwidth,keepaspectratio]{fourier_series_tri}
+%\captionof{figure}{zeitlicher Verlauf sowie Fourierkoeffizienten der Dreieckschwingung, ihrer Verschiebung sowie deren Faltung}
+\end{minipage}\\
+
+%Fourierkoeffizienten Rechteckschwingung
+%\begin{gather}
+% c_0=2\int_0^{\frac{T_h}{2}}A\mathrm{d}t
+%= 2At\Bigg |_{t=0}^{t=\frac{T_h}{2}}=A\cdot T_h\\
+% c_k=\int_{-\frac{T_h}{2}}^{\frac{T_h}{2}}A\e^{-\im k \omega_0 t}\mathrm{d}t=\frac{A}{\im k \omega_0}\left(\e^{\im \pi k \frac{T_h}{T}}-\e^{-\im \pi k \frac{T_h}{T}}\right)\\
+% =\frac{AT}{\im k 2\pi }\left(\e^{\im \pi k \frac{T_h}{T}}-\e^{-\im \pi k \frac{T_h}{T}}\right)
+% =\frac{AT}{k\pi}\sin(\pi k \frac{T_h}{T})\\
+% =\frac{AT}{k\pi}\frac{T_h}{T_h}\sin(\pi k \frac{T_h}{T})={AT_h}\frac{\sin(\pi k \frac{T_h}{T})}{\pi k \frac{T_h}{T}}=A\cdot T_h\mathrm{sinc}(\pi k \frac{T_h}{T})
+%\end{gather}
+%%%$x(t)\ast y(t)
+%\begin{gather}
+% x(t)\ast y(t)=\begin{cases}
+% \int_{t-T_h}^{-T+\frac{T_h}{2}}\frac{A^2}{2}\mathrm{d}\tau=\frac{A^2}{2}\left(-T+\frac{T_h}{2}-t+T_h\right)=-\frac{A^2}{2}\left(t+T-3\frac{T_h}{2}\right)&,-\frac{T}{2}\leq t \leq -\frac{T_h}{2}\\
+% \int_{-\frac{T_h}{2}}^{t}\frac{A^2}{2}\mathrm{d}\tau=\frac{A^2}{2}\left(t+\frac{T_h}{2}\right)&,\frac{-T_h}{2}\leq t \leq \frac{T_h}{2} \\
+% \int_{t-T_h}^{\frac{T_h}{2}}\frac{A^2}{2}\mathrm{d}\tau=\frac{A^2}{2}\left(\frac{T_h}{2}-t+T_h\right)=-\frac{A^2}{2}\left(t-3\frac{T_h}{2}\right)&,\frac{T_h}{2}\leq t \leq \frac{T}{2}
+% \end{cases}
+%\end{gather}
+
+%Fourierkoeffizienten Dreieckschwingung
+
+%\begin{gather}
+% c_k = \int_{-\frac{T_h}{2}}^{+\frac{T_h}{2}}x(t)\e^{-\im k \omega t}\mathrm{d}t=\int_{-\frac{T_h}{2}}^0\left(\frac{2A}{T_h}t+A\right)\e^{-\im k \omega t}\mathrm{d}t+\int_0^{+\frac{T_h}{2}}\left(-\frac{2A}{T_h}t+A\right)\e^{-\im k \omega t}\mathrm{d}t\\
+% =\frac{\left(\frac{2A}{T_h}t+A\right)}{-\im k \omega }\e^{-\im k \omega t}\Bigg|_{t=-\frac{T_h}{2}}^{0}+\int_{-\frac{T_h}{2}}^0\frac{\left(\frac{2A}{T_h}\right)}{\im k \omega }\e^{-\im k \omega t}\mathrm{d}t+\frac{\left(-\frac{2A}{T_h}t+A\right)}{-\im k \omega }\e^{-\im k \omega t}\Bigg|_{t=0}^{+\frac{T_h}{2}}-\int_0^{+\frac{T_h}{2}}\frac{\left(\frac{2A}{T_h}\right)}{\im k \omega }\e^{-\im k \omega t}\mathrm{d}t\\
+% =-\frac{A}{\im k \omega }+\frac{\left(\frac{2A}{T_h}\right)}{k^2\omega^2}\e^{-\im k \omega t}\Bigg |_{t=-\frac{T_h}{2}}^{t=0}+\frac{A}{\im k \omega}+\frac{\left(\frac{2A}{T_h}\right)}{k^2\omega^2}\e^{-\im k \omega t}\Bigg |_{t=+\frac{T_h}{2}}^{t=0}\\
+% =\frac{\left(\frac{2A}{T_h}\right)}{k^2\omega^2}\left[2-\e^{\im k \omega \frac{T_h}{2}}-\e^{-\im k \omega \frac{T_h}{2}}\right]=\frac{\left(\frac{4A}{T_h}\right)}{k^2\omega^2}\left[1-\cos(k\pi\frac{T_h}{T})\right]
+%\end{gather}
+%Es gilt (vgl. \cite[Kap. 2 S. 83]{Bronstein}):
+%\begin{gather}
+% \sin^2(\alpha)=\frac{1}{2}(1-\cos(2\alpha))
+%\end{gather}
+%Also:
+%\begin{gather}
+% \frac{\left(\frac{4A}{T_h}\right)}{k^2\omega^2}\left[1-\cos(k\pi\frac{T_h}{T})\right]=\frac{\left(\frac{4AT^2}{T_h}\right)}{k^24\pi^2}\left[1-\cos(k\pi\frac{T_h}{T})\right]=\frac{2AT^2}{T_hk^2\pi^2}\cdot\frac{1}{2}\left[1-\cos\left(2k\pi\frac{T_h}{2T}\right)\right]\\
+% =\frac{2AT^2}{T_hk^2\pi^2}\left[\sin^2\left(k\pi\frac{T_h}{2T}\right)\right]=\frac{T_hA}{2}\frac{4T^2}{T_h^2k^2\pi^2}\left[\sin^2\left(k\pi\frac{T_h}{2T}\right)\right]=\frac{A\cdot T_h}{2}\sinc^2\left(k\pi\frac{T_h}{2T}\right)
+%\end{gather}
+
+\columnbreak
+\subsection{Fourier Transform (FT)}
+%
+%
+\begin{itemize}
+\setlength\itemsep{-0.5em}
+\item continuous-time signal $x(t)$
+%
+\item continuous-frequency, non-periodic spectrum $X(\omega)$
+%
+\item $t, \omega\in\mathbb{R}$
+%
+\end{itemize}
+%
+\begin{align*}
+X(\omega) = \int\limits_{-\infty}^{+\infty} x(t) \,\e^{-\im \omega t}\,\mathrm{d}t
+\qquad
+x(t) = \frac{1}{2\pi}\int\limits_{-\infty}^{+\infty} X(\omega) \,\e^{+\im \omega t}\,\mathrm{d}\omega
+\end{align*}
+%Fourier Trafo
+\begin{minipage}{\columnwidth}
+\includegraphics[width=\columnwidth,keepaspectratio]{continuous_fouriertrafo_rect}
+\end{minipage}
+
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{continuous_fouriertrafo_tri}
+\end{minipage}
+
+
+
+
+\columnbreak
+%\hspace{2cm}
+\section{Discrete-Time Domain}
+%
+\begin{itemize}
+\setlength\itemsep{-0.5em}
+%
+\item time/sample index $k$
+%
+\item sampling interval $T_s$, sampling frequency $f_s = \frac{1}{T_s}$
+%
+\item temporal sampling: $\omega \cdot t \rightarrow \omega \cdot T_s k = \Omega k$
+%
+\item angular frequency $\Omega = \omega T_s = 2 \pi f T_s = 2 \pi \frac{f}{f_s}$
+%
+\end{itemize}
+
+
+\subsection{Fundamental Signals}
+
+\subsection{z-Transform}
+%
+\begin{align*}
+X(z) = \sum\limits_{k=-\infty}^{+\infty} x[k] \,z^{-k}
+\qquad
+x[k] = \frac{1}{2\pi\im}\oint\limits_{C}^{} X(z) \,z^{k-1}\,\mathrm{d}z
+\end{align*}
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{zTrafo}
+\end{minipage}
+\columnbreak
+\subsection{Discrete-Time Fourier Transform (DTFT)}
+%
+\begin{itemize}
+\setlength\itemsep{-0.5em}
+\item discrete-time signal $x[k]$
+%
+\item continuous-frequency, periodic spectrum $X(\Omega)$
+%
+\item $k,\nu\in\mathbb{Z}$ and $\Omega\in\mathbb{R}$
+%
+\item $2\pi$-periodicity: $X(\Omega)=X(\Omega+\nu2\pi)$
+\end{itemize}
+%
+\begin{align*}
+X(\Omega) = \sum\limits_{k=-\infty}^{+\infty} x[k] \,\e^{-\im \Omega k}
+\qquad
+x[k] = \frac{1}{2\pi}\int\limits_{0}^{2\pi} X(\Omega) \,\e^{+\im \Omega k}\,\mathrm{d}\Omega
+\end{align*}
+%
+%
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{DTFT_rect.pdf}
+\end{minipage}
+
+%DTFT eines Dreieickes:
+%Faltung von $\mathrm{rect}_[k]$ mit sich selbst ergibt ein Dreieck der Länge
+%$2N+1$ mit Maximum bei N-1.
+%%
+%DTFT durch Multiplikation der DTFTs des Rechtecksignals:
+%%
+%\begin{gather}
+% \mathrm{rect}_N[k]\ast\mathrm{rect}_N[k]\quad\fourier\quad\e^{-\im\Omega(N-1)}\cdot\frac{\sin^2(N\frac{\Omega}{2})}{\sin^2(\frac{\Omega}{2})}
+%\end{gather}
+%%
+%Mittelpunkt des Dreiecks soll bei 0 liegen, also Verschiebung um $N-1$ nach
+%links.
+%%
+%Durch Faltung steigt das Dreieck jeweils um 1 bis zu einem Maximum
+%bei $N-1$ von $N$.
+%%
+%\begin{gather}
+% N\cdot \mathrm{tri}_{2N+1}[k]=\e^{-\im\Omega(N-1)}\cdot\frac{\sin^2(N\frac{\Omega}{2})}{\sin^2(\frac{\Omega}{2})}\cdot\e^{+j\Omega(N-1)}=\frac{\sin^2(N\frac{\Omega}{2})}{\sin^2(\frac{\Omega}{2})}
+%\end{gather}
+%%
+%N muss noch auf die andere Seite gebracht werden.
+%%
+%\begin{gather}
+% \mathrm{tri}_{2N+1}[k]\quad\fourier\quad\frac{1}{N}\cdot\frac{\sin^2(N\frac{\Omega}{2})}{\sin^2(\frac{\Omega}{2})}
+%\end{gather}
+%%
+%Dies ist eine Korrespondenz für einen Dreiecksimpuls der Länge $2N+1$ mit der
+%Spitz bei $k=0$.
+%%
+%\begin{gather}
+% \mathrm{tri}_N[k]=
+% \begin{cases}
+% 1-\frac{k}{N}, &0 \leq k \leq N,\\
+% 1+\frac{k}{N}, &-N\leq k < 0,\\
+% 0, &\text{sonst}.
+% \end{cases}
+%\end{gather}
+%%
+%%
+%%
+%\begin{gather}
+% \lim\limits_{\Omega\rightarrow0}\frac{1}{N}\cdot\frac{\sin^2(N\frac{\Omega}{2})}{\sin^2(\frac{\Omega}{2})}
+% %
+% =\lim\limits_{\Omega\rightarrow0}\frac{1}{N}\cdot\frac{2\sin\left(N\frac{\Omega}{2}\right)\cos\left(N\frac{\Omega}{2}\right)\frac{N}{2}}{2\sin\left(\frac{\Omega}{2}\right)\cos\left(\frac{\Omega}{2}\right)\frac{1}{2}}\\
+% %
+% =\lim\limits_{\Omega\rightarrow0}
+% \frac{
+% %Zaehlers
+% \cos^2\left(N\frac{\Omega}{2}\right)\frac{N}{2}-\sin^2\left(N\frac{\Omega}{2}\right)\frac{N}{2}
+% }
+% %Nenner
+% {
+% \cos^2\left(\frac{\Omega}{2}\right)\frac{1}{2}-\sin^2\left(\frac{\Omega}{2}\right)\frac{1}{2}
+% }
+% =N
+%\end{gather}
+%
+%
+%
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{DTFT_tri.pdf}
+\end{minipage}
+%
+\columnbreak
+\subsection{Discrete Fourier Transform (DFT)}
+%
+\begin{itemize}
+\setlength\itemsep{-0.5em}
+\item discrete-time, periodic signal $x[k]$
+%
+\item discrete-frequency, periodic spectrum $X[\mu]$
+%
+\item $k,\mu,\nu\in\mathbb{Z}$
+%
+\item $N$-periodicity: $x[k]=x[k + \nu N]$ and $X[\mu]=x[\mu + \nu N]$
+\end{itemize}
+%
+\begin{align*}
+X[\mu] = \sum\limits_{k=0}^{N-1} x[k] \,\e^{-\im \frac{2\pi}{N} \mu k}
+\qquad
+x[k] = \frac{1}{N}\sum\limits_{\mu=0}^{N-1} X[\mu] \,\e^{+\im \frac{2\pi}{N} \mu k}
+\end{align*}
+
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{DFT_rect.pdf}
+\end{minipage}
+
+\begin{minipage}{\columnwidth}
+ \includegraphics[width=\columnwidth,keepaspectratio]{DFT_tri.pdf}
+\end{minipage}
+\columnbreak
+
+\section{Signals and Systems Cheat Sheet}
+\href{https://github.com/robhau}{Robert Hauser},
+\href{https://orcid.org/0000-0002-3010-0294}{Frank Schultz},
+University of Rostock\\
+\tiny
+\url{https://github.com/spatialaudio/signals-and-systems-cheatsheet}
+\normalsize
+\begin{description}
+\item[v0.00 - 2021/xx/xx] TBD
+\end{description}
+\nocite{sigsysex,Bronstein}
+\bibliography{literatur}
+\bibliographystyle{ieeetran}
+\end{document}