summaryrefslogtreecommitdiff
path: root/Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb
diff options
context:
space:
mode:
authorPrashant S2020-04-14 10:25:32 +0530
committerGitHub2020-04-14 10:25:32 +0530
commit06b09e7d29d252fb2f5a056eeb8bd1264ff6a333 (patch)
tree2b1df110e24ff0174830d7f825f43ff1c134d1af /Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb
parentabb52650288b08a680335531742a7126ad0fb846 (diff)
parent476705d693c7122d34f9b049fa79b935405c9b49 (diff)
downloadall-scilab-tbc-books-ipynb-master.tar.gz
all-scilab-tbc-books-ipynb-master.tar.bz2
all-scilab-tbc-books-ipynb-master.zip
Merge pull request #1 from prashantsinalkar/masterHEADmaster
Initial commit
Diffstat (limited to 'Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb')
-rw-r--r--Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb262
1 files changed, 262 insertions, 0 deletions
diff --git a/Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb b/Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb
new file mode 100644
index 0000000..befae0e
--- /dev/null
+++ b/Digital_Signal_Processing_by_S_Salivahanan/11-Multirate_Digital_Signal_Processing.ipynb
@@ -0,0 +1,262 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 11: Multirate Digital Signal Processing"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.1: Time_Decimatio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 11.1\n",
+"\n",
+"clc;clear;close;\n",
+"x=[0:6 0:6];\n",
+"y=x(1:3:length(x));\n",
+"disp(x,'Input signal x(n)=');\n",
+"disp(y,'Output signal of decimation process by factor three y(n)');\n",
+"subplot(2,1,1);\n",
+"plot2d3(x);title('Input signal x(n)');\n",
+"subplot(2,1,2);\n",
+"plot2d3(y);title('Output signal y(n)');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.2: Interpolation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 11.2\n",
+"\n",
+"clc;clear;close;\n",
+"x=0:5;\n",
+"y=[];\n",
+"for i=1:length(x)\n",
+" y(1,2*i)=x(i);\n",
+"end\n",
+"disp(x,'Input signal x(n)=');\n",
+"disp(y,'Output signal of interpolation process with factor two y(n)');\n",
+"subplot(2,1,1);\n",
+"plot2d3(x);title('Input signal x(n)');\n",
+"subplot(2,1,2);\n",
+"plot2d3(y);title('Output signal y(n)');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.4: Polyphase_Decompositio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 11.4\n",
+"\n",
+"clc;clear;\n",
+"z=poly(0,'z');\n",
+"num=1-4*z^-1;\n",
+"den=1+5*z^-1;\n",
+"H=num/den;\n",
+"num1=num*(1-5*z^-1);\n",
+"den1=den*(1-5*z^-1);\n",
+"H1=num1/den1;\n",
+"c=coeff(numer(num1));\n",
+"clength=length(c);\n",
+"c=[c zeros(1,pmodulo(clength,2))]; //make length of 'c' multiple of 2\n",
+"c0=[];c1=[];\n",
+"for n=1:ceil(clength/2) //loop to separate even and odd powers of z\n",
+" c0=[c0 c(2*n-1) 0];\n",
+" c1=[c1 c(2*n) 0];\n",
+"end\n",
+"E0=poly(c0,'z','coeff')/z^n/den1;\n",
+"E1=poly(c1,'z','coeff')/z^(n-2)/den1;\n",
+"disp('Polyphase Components')\n",
+"disp(E0,'E0(z)');\n",
+"disp(E1,'E1(z)');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.5: Decimator_implementation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 11.5\n",
+"\n",
+"clc;clear;\n",
+"\n",
+"function [N,R]=func(Fs,Fp,Ft,Fti,dp,ds,M)\n",
+" dF=(Fs-Fp)/Ft; //Normalised transition bandwidth\n",
+" N=round((-20*log10(sqroot(dp*ds))-13)/(14.6*dF)); //FIR Filter length\n",
+" R=N*Fti/M; //Number of Multiplications per second\n",
+"endfunction\n",
+"\n",
+"Ft=20000; //Sampling rate of input signal\n",
+"Fp=40; //Passband frequency\n",
+"Fs=50; //Stopband frequency\n",
+"dp=0.01; //Passband ripple\n",
+"ds=0.002; //Stopband ripple\n",
+"M=100; //Decimation Factor\n",
+"Fti=Ft; //Input sampling rate\n",
+"//Single stage implementation\n",
+"[N1,R1]=func(Fs,Fp,Ft,Fti,dp,ds,M);\n",
+"\n",
+"//Two stage implementation\n",
+"//Stage 1 F(z) with decimation factor 50\n",
+"Fpf=Fp; //Passband frequency\n",
+"Fsf=190; //Stopband frequency\n",
+"dpf=0.005; //Passband ripple\n",
+"dsf=0.002; //Stopband ripple\n",
+"Mf=50; //Decimation Factor\n",
+"Fti=Ft; //Input sampling rate\n",
+"[N2f,R2f]=func(Fsf,Fpf,Ft,Fti,dpf,dsf,Mf);\n",
+"\n",
+"//Stage 2 G(z) with decimation factor 2\n",
+"Fpg=50*Fp; //Passband frequency\n",
+"Fsg=50*Fs; //Stopband frequency\n",
+"dpg=0.005; //Passband ripple\n",
+"dsg=0.002; //Stopband ripple\n",
+"Mg=2; //Decimation Factor\n",
+"Fti=Ft/50; //Input sampling rate\n",
+"[N2g,R2g]=func(Fsg,Fpg,Ft,Fti,dpg,dsg,Mg);\n",
+"N2=N2f+50*N2g+2; //Total filter length\n",
+"R2=R2f+R2g; //Total Number of Multiplications per second\n",
+"disp(R1,'Number of Multiplications per second =',N1,'FIR filter length =','For Single stage implementation:');\n",
+"disp('For Two stage implementation:');\n",
+"disp(R2f,'Number of Multiplications per second =',N2f,'FIR filter length =','For F(z):');\n",
+"disp(R2g,'Number of Multiplications per second =',N2g,'FIR filter length =','For G(z):');\n",
+"disp(R2,'Total Number of Multiplications per second =',N2,'Overall FIR filter length =');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.6: Decimator_implementation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 11.6\n",
+"\n",
+"clc;clear;\n",
+"\n",
+"\n",
+"function [N,R]=func(Fs,Fp,Ft,Fti,dp,ds,M)\n",
+" dF=(Fs-Fp)/Ft; //Normalised transition bandwidth\n",
+" N=round((-20*log10(sqroot(dp*ds))-13)/(14.6*dF)); //FIR Filter length\n",
+" R=N*Fti/M; //Number of Multiplications per second\n",
+"endfunction\n",
+"\n",
+"Ft=10000; //Sampling rate of input signal\n",
+"Fp=150; //Passband frequency\n",
+"Fs=180; //Stopband frequency\n",
+"dp=0.002; //Passband ripple\n",
+"ds=0.001; //Stopband ripple\n",
+"M=20; //Decimation Factor\n",
+"Fti=Ft; //Input sampling rate\n",
+"//Single stage implementation\n",
+"[N1,R1]=func(Fs,Fp,Ft,Fti,dp,ds,M);\n",
+"\n",
+"//Two stage implementation\n",
+"//Stage 1 F(z) with decimation factor 50\n",
+"Fpf=Fp; //Passband frequency\n",
+"Fsf=720; //Stopband frequency\n",
+"dpf=0.001; //Passband ripple\n",
+"dsf=0.001; //Stopband ripple\n",
+"Mf=10; //Decimation Factor\n",
+"Fti=Ft; //Input sampling rate\n",
+"[N2f,R2f]=func(Fsf,Fpf,Ft,Fti,dpf,dsf,Mf);\n",
+"\n",
+"//Stage 2 G(z) with decimation factor 2\n",
+"Fpg=10*Fp; //Passband frequency\n",
+"Fsg=10*Fs; //Stopband frequency\n",
+"dpg=0.001; //Passband ripple\n",
+"dsg=0.001; //Stopband ripple\n",
+"Mg=2; //Decimation Factor\n",
+"Fti=Ft/10; //Input sampling rate\n",
+"[N2g,R2g]=func(Fsg,Fpg,Ft,Fti,dpg,dsg,Mg);\n",
+"N2=N2f+10*N2g+2; //Total filter length\n",
+"R2=R2f+R2g; //Total Number of Multiplications per second\n",
+"\n",
+"disp(R1,'Number of Multiplications per second =',N1,'FIR filter length =','For Single stage implementation:');\n",
+"disp('For Two stage implementation:');\n",
+"disp(R2f,'Number of Multiplications per second =',N2f,'FIR filter length =','For F(z):');\n",
+"disp(R2g,'Number of Multiplications per second =',N2g,'FIR filter length =','For G(z):');\n",
+"disp(R2,'Total Number of Multiplications per second =',N2,'Overall FIR filter length =');"
+ ]
+ }
+],
+"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
+}