{
 "metadata": {
  "name": "",
  "signature": "sha256:344aa83aae7640fc5c3f2bc230bb6d0ed2b2c16bf41e02ab7ccae093773e6e18"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER01:SIGNALS AND SPECTRA"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E09 : Pg 1.13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Page Number: 1.13\n",
      "# Example 1.9\n",
      "# Given,\n",
      "# Signal is x(t)= e^(-at) * u(t)\n",
      "# unity function u(t)=1 for 0 to infinity \n",
      "# therefore\n",
      "import math,numpy\n",
      "x=1;\n",
      "# We assume 'infinity' value as 10 and the value of 'a' is 1\n",
      "#t= 0:1:10;\n",
      "t=numpy.linspace(0,10,num=11)\n",
      "a=1;#  a >0\n",
      "z=((math.e)**(-a*t) * x);\n",
      "y=numpy.fft.fft(z);\n",
      "print 'fourier transform of x(t)=',y"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "fourier transform of x(t)= [ 1.58195029+0.j          1.33722176-0.38516024j  1.02105993-0.4033185j\n",
        "  0.84862839-0.29364174j  0.76732853-0.17191927j  0.73478625-0.05628763j\n",
        "  0.73478625+0.05628763j  0.76732853+0.17191927j  0.84862839+0.29364174j\n",
        "  1.02105993+0.4033185j   1.33722176+0.38516024j]\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 : Pg 1.14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Page Number: 1.14\n",
      "# Example 1.10\n",
      "# Given,\n",
      "# Signal is x(t)= e**|-a|t * u(t)\n",
      "# unity function u(t)=1 for 0 to infinity \n",
      "# therefore\n",
      "import numpy,math\n",
      "x=1;\n",
      "# We assume 'infinity' value as 10 and the value of 'a' is 1\n",
      "t= numpy.linspace(0,10,num=11);\n",
      "a1=1;#  For a >0\n",
      "a2=-1; # For a <0\n",
      "z=((math.e)**(a2*t) * x)+((math.e)**(a1*t) * x);\n",
      "y=numpy.fft.fft(z);\n",
      "print'fourier transform of x(t)=',y"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "fourier transform of x(t)= [ 34846.35579562    +0.j          20193.20071216+23060.75353691j\n",
        "   1262.96607876+24147.94540875j  -9061.39666752+17581.25336274j\n",
        " -13929.23742795+10293.34682733j -15877.71059326 +3370.11697016j\n",
        " -15877.71059326 -3370.11697016j -13929.23742795-10293.34682733j\n",
        "  -9061.39666752-17581.25336274j   1262.96607876-24147.94540875j\n",
        "  20193.20071216-23060.75353691j]\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 : Pg 1.14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Page Number: 1.14\n",
      "# Example 1.11\n",
      "# (a)\n",
      "# Given\n",
      "# Signal is x(t) = rect(t)\n",
      "# rect(t) = 1 for -a< |t| < a and 0 elsewhere\n",
      "# Therefore\n",
      "# We find out fourier transform of x(t)= 1 for -a< |t| < a thus,\n",
      "import math,numpy\n",
      "x=([1]);\n",
      "a= 200; # Assume \n",
      "t= numpy.linspace(-a,a,num=2*a+1); # range for fourier transform\n",
      "y=numpy.fft.fft(x);\n",
      "print'Fourier transform of x(t)=',y\n",
      "\n",
      "\n",
      "# (b)\n",
      "\n",
      "# Given\n",
      "# Signal is x(t) = rect(t)\n",
      "# rect(t) = 1 for -a/4< |t| < a/4 and 0 elsewhere\n",
      "# Therefore\n",
      "# We find out fourier transform of x(t)= 1 for -a/4< |t| < a/4 thus,\n",
      "import numpy\n",
      "x=([1]);\n",
      "a= 200; # Assume \n",
      "t= numpy.linspace(-a/4,a/4,num=(a/2)+1);# range for fourer transform\n",
      "y=numpy.fft.fft(x);\n",
      "print'Fourier transform of x(t)=',y\n",
      "\n",
      "# (c)\n",
      "\n",
      "# Given\n",
      "# Signal is x(t) = rect(t)\n",
      "# rect(t) = 1 for b < |t| < b + a/2 and 0 elsewhere\n",
      "# Therefore\n",
      "# We find out fourier transform of x(t)= 1 for b < |t| < b+ a/2 thus,\n",
      "import numpy\n",
      "x=([1]);\n",
      "a= 200; # Assume \n",
      "b=100; # Assume\n",
      "t=numpy.linspace(b,(b+(a/2)),num=((a/2)+1)) ;# range for fourer transform\n",
      "y=numpy.fft.fft(x);\n",
      "print'Fourier transform of x(t)=',y"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fourier transform of x(t)= [ 1.+0.j]\n",
        "Fourier transform of x(t)= [ 1.+0.j]\n",
        "Fourier transform of x(t)= [ 1.+0.j]\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}