{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 5: Frequency Domain Analysis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.1: Sinusoidal_plots_for_increasing_frequency.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Sinusoidal plots for increasing frequency\n", "// 5.1\n", "\n", "exec('stem.sci',-1);\n", "\n", "n=0:16;\n", "subplot(2,2,1), stem(n,cos(n*%pi/8))\n", "xgrid,xtitle('','n','cos(n*pi/8)')\n", "subplot(2,2,2), stem(n,cos(n*%pi/4))\n", "xgrid,xtitle('','n','cos(n*pi/4)')\n", "subplot(2,2,3), stem(n,cos(n*%pi/2))\n", "xgrid,xtitle('','n','cos(n*pi/2)')\n", "subplot(2,2,4), stem(n,cos(n*%pi))\n", "xgrid,xtitle('','n','cos(n*pi)')\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.2: Bode_plots.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Bode plots for Example 5.7 on page 141\n", "// 5.2\n", "\n", "exec('label.sci',-1);\n", "\n", "omega = linspace(0,%pi);\n", "g1 = 0.5 ./ (cos(omega)-0.5+%i*sin(omega));\n", "mag1 = abs(g1);\n", "angle1 = phasemag(g1);\n", "g2 = (0.5+0.5*cos(omega)-1.5*%i*sin(omega)) ...\n", " * 0.25 ./ (1.25-cos(omega));\n", "mag2 = abs(g2);\n", "angle2 = phasemag(g2);\n", "subplot(2,1,1)\n", "plot(omega,mag1,omega,mag2,'--');\n", "label('',4,' ','Magnitude',4);\n", "subplot(2,1,2); \n", "plot(omega,angle1,omega,angle2,'--');\n", "label('',4,'w (rad/s)','Phase',4);\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.3: Bode_plot_of_the_moving_average_filter.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Bode plot of the moving average filter, discussed in Example 5.5 on page 129\n", "// 5.3\n", "\n", "exec('label.sci',-1);\n", "\n", "w = 0.01:0.01:%pi;\n", "subplot(2,1,1);\n", "mag = abs(1+2*cos(w))/3;\n", "plot2d('ll',w,mag,2);\n", "label('',4,' ','Magnitude',4);\n", "subplot(2,1,2);\n", "plot2d('ln',w,phasemag(1+2*cos(w)),style = 2,rect =[0.01 -0.5 10 200]);\n", "label('',4,'w','Phase',4)\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.4: Bode_plot_of_the_differencing_filter.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Bode plot of the differencing filter, discussed in Example 5.6 on page 130\n", "// 5.4\n", "\n", "exec('label.sci',-1);\n", "\n", "w = 0.01:0.01:%pi;\n", "G = 1-exp(-%i*w);\n", "subplot(2,1,1)\n", "plot2d1('gll',w,abs(G),style = 2);\n", "label('',4,' ','Magnitude',4);\n", "subplot(2,1,2)\n", "plot2d1('gln',w,phasemag(G),style = 2);\n", "label('',4,'w','Phase',4)\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.5: Bode_plot_of_minimum_and_nonminimum_phase_filters.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Bode plot of minimum and nonminimum phase filters, discussed in Example 5.9 on page 145\n", "// 5.5\n", "\n", "exec('label.sci',-1);\n", "\n", "omega = linspace(0,%pi);\n", "ejw = exp(-%i*omega);\n", "G1 = 1.5*(1-0.4*ejw); \n", "mag1 = abs(G1); angle1 = phasemag(G1);\n", "G2 = -0.6*(1-2.5*ejw);\n", "mag2 = abs(G2); angle2 = phasemag(G2);\n", "subplot(2,1,1);\n", "plot(omega,mag1,omega,mag2,'--');\n", "label('',4,' ','Magnitude',4);\n", "subplot(2,1,2);\n", "plot(omega,angle1,omega,angle2,'--');\n", "label('',4,'w (rad/s)','Phase',4);\n", "" ] } ], "metadata": { "kernelspec": { "display_name": "Scilab", "language": "scilab", "name": "scilab" }, "language_info": { "file_extension": ".sce", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "scilab", "version": "0.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }