·

Engenharia Eletrônica ·

Sinais e Sistemas

Envie sua pergunta para a IA e receba a resposta na hora

Fazer Pergunta

Texto de pré-visualização

Scilab Manual for Digital Signal Processing by Ms E Sangeetha Devi Electronics Engineering Periyar Maniammai University1 Solutions provided by Ms ESANGEETHA DEVI Electronics Engineering PERIYAR MANIAMMAI UNIVERSITYTHANAJAVUR March 5 2018 1Funded by a grant from the National Mission on Education through ICT httpspokentutorialorgNMEICTIntro This Scilab Manual and Scilab codes written in it can be downloaded from the Migrated Labs section at the website httpscilabin Contents List of Scilab Solutions 3 1 GENERATION OF CONTINUOUS SIGNALS 6 2 GENERATION OF DISCRETE SIGNALS 13 3 GENERATION OF SINUSOIDAL SIGNALS 18 4 GENERATION OF COMPLEX EXPONENTIAL SIGNALS 20 5 EXPONENTIALLY GROWING DECAYING SIGNAL 23 6 ADDITION OF TWO CONTINUOUS SIGNALS 26 7 ADDITION OF TWO DISCRETE SIGNALS 28 8 PROGRAM FOR SAMPLING PROCESS 30 9 PROGRAM FOR ALIASING PROCESS 32 10 LINEAR CONVOLUTION OF TWO SEQUENCES 34 11 CIRCULAR CONVOLUTION OF TWO SEQUENCES 37 12 DFT OF A SIGNAL 40 13 FFT OF A SIGNAL 44 2 List of Experiments Solution 11sinewave 6 Solution 12cosine wave 6 Solution 13triangular wave 8 Solution 14signum function 9 Solution 15sinc function 11 Solution 16Exponential wave 12 Solution 21unit impulse signal 13 Solution 22unitstepsignal 13 Solution 23discreteexponentialwave 15 Solution 24unit ramp 16 Solution 31Generation of sinusoidal signals 18 Solution 41generation of complex exponential signals 20 Solution 51Exponentially Growing signals 23 Solution 52Exponentially decaying signals 24 Solution 61Addition of two continuous signals 26 Solution 71Addition of two discrete signals 28 Solution 81sampling 30 Solution 91Aliasing process 32 Solution 101linear convolution of two sequences 34 Solution 111circular convolution 37 Solution 121DFT 40 Solution 131fast fourier transform 44 3 List of Figures 11 sinewave 7 12 cosine wave 7 13 triangular wave 8 14 signum function 9 15 sinc function 10 16 Exponential wave 11 21 unit impulse signal 14 22 unitstepsignal 14 23 discreteexponentialwave 15 24 unit ramp 16 31 Generation of sinusoidal signals 19 41 generation of complex exponential signals 21 51 Exponentially Growing signals 24 52 Exponentially decaying signals 25 61 Addition of two continuous signals 27 71 Addition of two discrete signals 29 81 sampling 31 91 Aliasing process 33 101 linear convolution of two sequences 36 111 circular convolution 38 121 DFT 41 4 131 fast fourier transform 45 5 Experiment 1 GENERATION OF CONTINUOUS SIGNALS Scilab code Solution 11 sinewave 1 clc 2 clf 3 clear all 4 Caption g e n e r a t i o n of s i n e wave 5 f02 6 t00110 7 xsin 2 pitf 8 plottx 9 title s i n e wave 10 xlabel t 11 ylabel x Scilab code Solution 12 cosine wave 6 Figure 11 sinewave Figure 12 cosine wave 7 Figure 13 triangular wave 1 clc 2 clf 3 clear all 4 Caption g e n e r a t i o n of c o s i n e wave 5 f02 6 t00110 7 xcos 2 pitf 8 plottx 9 title cosne wave 10 xlabel t 11 ylabel x Scilab code Solution 13 triangular wave 8 Figure 14 signum function 1 clc 2 clf 3 clear all 4 Caption g e n e r a t i o n of t r i a n g u l a r wave 5 a8 6 t0 pi 4 4 pi 7 yasin 2t 8 agca 9 axlocation middle 10 plotty 11 title t r i a n g u l a r wave 12 xlabel t 13 ylabel y 9 Figure 15 sinc function Scilab code Solution 14 signum function 1 clc 2 clf 3 clear all 4 Caption signum f u n c t i o n 5 t 5015 6 agca 7 axlocation middle 8 xsignt 9 b gca 10 bylocation middle 11 plottx 12 title signum f u n c t i o n 10 Figure 16 Exponential wave Scilab code Solution 15 sinc function 1 clc 2 clf 3 clear all 4 Caption s i n c f u n c t i o n 5 t 100110 6 xsinct 7 plottx 8 title s i n c wave 9 xlabel t 10 ylabel x 11 Scilab code Solution 16 Exponential wave 1 clc 2 clf 3 clear all 4 Caption g e n e r a t i o n of e x p o n e n t i a l wave 5 t 2012 6 xexpt 7 plottx 8 title e x p o n e n t i a l wave 9 xlabel t 10 ylabel x 12 Experiment 2 GENERATION OF DISCRETE SIGNALS Scilab code Solution 21 unit impulse signal 1 clc 2 clf 3 clear all 4 unit impulse 5 L5 6 nLL 7 x zeros1Lones 11zeros1L 8 agca 9 aylocation middle 10 plot2d3nx 11 title unit impulse Scilab code Solution 22 unitstepsignal 13 Figure 21 unit impulse signal Figure 22 unitstepsignal 14 Figure 23 discreteexponentialwave 1 clc 2 clf 3 clear all 4 L5 5 nLL 6 x zeros1Lones1L1 7 agca 8 aylocation middle 9 plot2d3nx 10 title unit step 11 xlabel n 12 ylabel x Scilab code Solution 23 discreteexponentialwave 15 Figure 24 unit ramp 1 unit e x p o n e n t i a l 2 clc 3 clf 4 clear all 5 a1 6 xexpat 7 plot2d3x 8 title e x p o n e n t i a l s i g n a l 9 xlabel t 10 ylabel x Scilab code Solution 24 unit ramp 1 unit ramp 16 2 clc 3 clf 4 clear all 5 L5 6 nLL 7 x zeros1L 0L 8 a gca 9 aylocation middle 10 plot2d3nx 11 xtitle unit ramp s i g n a l 12 xlabel n 13 ylabel x n 17 Experiment 3 GENERATION OF SINUSOIDAL SIGNALS Scilab code Solution 31 Generation of sinusoidal signals 1 clc 2 clear all 3 tic 4 t001 pi 5 g e n e r a t i o n of s i n e s i g n a l s 6 y1sint 7 y2sin 3t3 8 y3sin 5t5 9 y4sin 7t7 10 y5sin 9t9 11 y sint sin 3t3 sin 5t5 sin 7t7 sin 9t9 12 plottyty1 ty2 ty3 ty4 ty5 13 legend y y1 y2 y3 y4 y5 14 title g e n e r a t i o n of sum of s i n u s o i d a l s i g n a l s 15 xgrid 1 16 ylabel Amplitude 18 Figure 31 Generation of sinusoidal signals 17 xlabel t 18 toc 19 Experiment 4 GENERATION OF COMPLEX EXPONENTIAL SIGNALS Scilab code Solution 41 generation of complex exponential signals 1 program f o r g e n e r a t i o n of complex e x p o n e n t i a l s i g n a l s 2 clc 3 clf 4 clear all 5 n 100110 6 a08 7 b 08 8 c125 9 d 125 10 x1an 11 subplot 221 12 plot2d3nx1 13 xlabel n 14 ylabel amplitude 20 Figure 41 generation of complex exponential signals 15 title complex e x p o n e n t i a l s i g n a l 0a1 16 x2bn 17 subplot 222 18 plot2d3nx2 19 xlabel n 20 ylabel amplitude 21 title complex e x p o n e n t i a l s i g n a l 1a0 22 x3cn 23 subplot 223 24 plot2d3nx3 25 xlabel n 26 ylabel amplitude 27 title complex e x p o n e n t i a l s i g n a l a1 28 x4dn 29 subplot 224 30 plot2d3nx4 31 xlabel n 32 ylabel amplitude 21 33 title complex e x p o n e n t i a l s i g n a l a1 22 Experiment 5 EXPONENTIALLY GROWING DECAYING SIGNAL Scilab code Solution 51 Exponentially Growing signals 1 Exp on en t ial l y decaying s i g n a l 2 clc 3 clf 4 clear all 5 disp Exp on en t i al l y Decaying s i g n a l 6 N2 7 a 01 8 n001N 9 xan 10 disp Exp on en t i al l y growing s i g n a l 11 dispx 12 plot2d3nx 13 xlabel Time 14 ylabel Amplitude 15 title Exp on en t i al l y growing S i g n a l Response 23 Figure 51 Exponentially Growing signals Scilab code Solution 52 Exponentially decaying signals 1 2 clc 3 clf 4 clear all 5 disp Exp on en t i al l y Decaying s i g n a l 6 N5 7 a 01 8 n001N 9 xan 10 disp Exp on en t i al l y decaying s i g n a l 11 dispx 12 plot2d3nx 13 xlabel Time 14 ylabel Amplitude 24 Figure 52 Exponentially decaying signals 15 title Exp on en t i al l y Decaying S i g n a l Response 25 Experiment 6 ADDITION OF TWO CONTINUOUS SIGNALS Scilab code Solution 61 Addition of two continuous signals 1 program f o r a d d i t i o n of two continuous s i g n a l s 2 clc 3 clf 4 clear all 5 t00130 6 x1sin 2 pit9 7 x2sin 2 pit2 8 x3x1x2 9 subplot 131 10 plottx1 11 title sinewave1 12 xlabel t 13 ylabel x1 t 14 subplot 132 15 plottx2 16 title sinewave2 17 xlabel t 26 Figure 61 Addition of two continuous signals 18 ylabel x2 t 19 subplot 133 20 plottx3 21 title a d d i t i o n of 2 s i g n a l s 22 xlabel t 23 ylabel x3 t 27 Experiment 7 ADDITION OF TWO DISCRETE SIGNALS Scilab code Solution 71 Addition of two discrete signals 1 program f o r a d d i t i o n of two d i s c r e t e s i g n a l s 2 N5 3 n001N1 4 x1sin 1 pin 5 x2sin 2 pin 6 x3x1x2 7 figure 1 8 subplot 131 9 plot2d3nx1 10 title s i n e wave1 11 xlabel n 12 ylabel x1 n 13 subplot 132 14 plot2d3nx2 15 title sinewave2 16 xlabel n 17 ylabel x2 n 28 Figure 71 Addition of two discrete signals 18 subplot 133 19 plot2d3nx3 20 title a d d i t i o n of 2 s i g n a l s 21 xlabel n 22 ylabel x3 n 29 Experiment 8 PROGRAM FOR SAMPLING PROCESS Scilab code Solution 81 sampling 1 program f o r sampling 2 clc 3 clf 4 clear all 5 t0001100 6 fm 002 7 xcos 2 pifmt 8 subplot 221 9 plottx 10 title c o n t i n i o u s time s i g n a l 11 fs1 0002 12 n0150 13 x1cos 2 pifmnfs1 14 subplot 222 15 plot2d3nx1 16 title time s i g n a l fs1 2fm 17 fs2 004 30 Figure 81 sampling 18 x2cos 2 pifmnfs2 19 subplot 223 20 plot2d3nx2 21 title time s i g n a l f s 2 2fm 22 fs3 04 23 x3cos 2 pifmnfs3 24 subplot 224 25 plot2d3nx3 26 title time s i g n a l fs3 2fm 31 Experiment 9 PROGRAM FOR ALIASING PROCESS Scilab code Solution 91 Aliasing process 1 program f o r e f f e c t of a l i a s i n g 2 clc 3 clf 4 clear all 5 fs 8000 6 t01 fs 001 7 f1000 2000 3000 3500 4000 4500 8000 8500 9000 8 i1 9 while i7 10 ysin 2 pifit 11 subplot 32i 12 plotty 13 xlabel frequency 14 ylabel amplitude 15 ii1 16 end 32 Experiment 10 LINEAR CONVOLUTION OF TWO SEQUENCES Scilab code Solution 101 linear convolution of two sequences 1 program f o r l i n e a r c o n v o l u t i o n 2 clc 3 clf 4 clear all 5 xinput Enter the f i r s t sequence 6 yinput Enter the second Sequence 7 nconvolxy 8 subplot 221 9 plot2d3x 10 title f i r s t sequence 11 xlabel n 12 ylabel amp 13 subplot 222 14 plot2d3y 15 title second sequence 16 xlabel n 17 ylabel amp 18 subplot 223 19 plot2d3n 34 20 title convolved sequence 21 xlabel n 22 ylabel amp 23 disp The convolved sequence i s 24 dispn 25 26 r e s u l t 27 Enter the f i r s t sequence 4 2 6 2 28 Enter the second Sequence 6 5 2 3 29 30 The convolved sequence i s 31 32 2 4 3 2 5 4 5 8 2 8 2 2 6 35 Figure 101 linear convolution of two sequences 36 Experiment 11 CIRCULAR CONVOLUTION OF TWO SEQUENCES Scilab code Solution 111 circular convolution 1 program f o r c i r c u l a r c o n v o l u t i o n 2 clc 3 clf 4 clear all 5 ginput Enter the f i r s t sequence 6 hinput Enter the second sequence 7 N1lengthg 8 N2lengthh 9 NmaxN1 N2 10 N3N1 N2 11 ifN3 0 then 12 hhzeros1N3 13 else 14 ggzeros1N3 15 end 16 for n1N 17 yn0 37 18 for i1N 19 jni1 20 ifj 0 21 jNj 22 end 23 ynyngihj 24 end 25 end 26 disp The r e s u l t a n t s i g n a l i s 27 dispy 28 subplot 311 29 plot2d3g 30 title f i r s t input sequence 31 subplot 312 32 plot2d3h 33 title second input sequence 34 subplot 313 35 plot2d3y 36 title convolved sequence 37 38 39 40 r e s u l t 41 Enter the f i r s t sequence 5 3 6 4 42 Enter the second sequence 2 6 5 3 43 44 The r e s u l t a n t s i g n a l i s 45 46 7 3 7 4 6 7 7 4 39 Experiment 12 DFT OF A SIGNAL Scilab code Solution 121 DFT 1 program f o r c a l c u l a t i o n of DFT of a s i g n a l 2 clc 3 clf 4 clear all 5 Ninput Enter the value of N 6 xinput e n t e r input sequence 7 for k1N 8 yk0 9 for n1N 10 ykykxnexpi2 pik1n1N 11 Arealy 12 Bimagy 13 end 14 end 15 magabsy 16 x1atanimagyrealy 17 phasex1 180 pi 18 disp the r e s u l t a n t DFT sequence i s 40 Figure 121 DFT 19 dispy 20 disp the r e s u l t a n t r e a l value i s 21 dispA 22 disp the r e s u l t a n t imaginary value i s 23 dispB 24 disp the magnitude response i s 25 dispmag 26 disp the phase r esponse i s 27 dispphase 28 for n1N 29 yn0 30 for k1N 31 ynyn1Nykexpi2 pik1n 1N 32 Crealx 33 end 34 end 35 disp the r e s u l t a n t IDFT sequence i s 41 36 dispC 37 subplot 421 38 plot2d3x 39 title input sequence 40 subplot 422 41 plot2d3A 42 title r e s u l t a n t DFT sequence 43 subplot 423 44 plot2d3A 45 title r e a l value 46 subplot 424 47 plot2d3B 48 title imaginary value 49 subplot 425 50 plot2d3mag 51 title magnitude responce 52 subplot 426 53 plot2d3phase 54 title phase responce 55 subplot 427 56 plot2d3C 57 title r e s u l t a n t IDFT sequence 58 59 60 r e s u l t 61 Enter the value of N 4 62 e n t e r input sequence 1 4 2 3 63 64 the r e s u l t a n t DFT sequence i s 65 66 1 0 1 i 4 1102D15 i 1 i 67 68 the r e s u l t a n t r e a l value i s 69 1 0 1 4 1 70 71 the r e s u l t a n t imaginary value i s 72 73 0 1 1102D15 1 42 74 75 the magnitude response i s 76 77 1 0 14142136 4 14142136 78 79 the phase r esp onse i s 80 81 0 135 180 135 82 83 the r e s u l t a n t IDFT sequence i s 84 85 1 4 2 3 43 Experiment 13 FFT OF A SIGNAL Scilab code Solution 131 fast fourier transform 1 program f o r c a l c u l a t i o n of FFT of a s i g n a l 2 clc 3 clf 4 clear all 5 Ninput Enter the value of N 6 xinput e n t e r input sequence 7 yfftx 8 Arealy 9 Bimagy 10 magabsy 11 x1atanimagyrealy 12 phasex1 180 pi 13 disp the r e s u l t a n t FFT sequence i s 14 dispy 15 disp the magnitude response i s 16 dispmag 17 disp the phase r esponse i s 18 dispphase 19 ziffty 44 Figure 131 fast fourier transform 20 disp the r e s u l t a n t IFFT sequence i s 21 dispz 22 subplot 321 23 plot2d3x 24 title input sequence 25 subplot 322 26 plot2d3A 27 title FFT r e a l sequence 28 subplot 323 29 plot2d3B 30 title FFT imaginary sequence 31 subplot 324 32 plot2d3mag 33 title magnitude r esponse 34 subplot 325 35 plot2d3phase 36 title phase r esp on se 37 subplot 326 38 plot2d3x 39 title IFFT sequence 40 45 41 42 r e s u l t 43 Enter the value of N 4 44 e n t e r input sequence 5 2 3 1 45 46 the r e s u l t a n t FFT sequence i s 47 48 1 1 2 i 5 2 i 49 50 the magnitude r esponse i s 51 52 1 1 2236068 5 2236068 53 54 the phase r espon se i s 55 56 0 26565051 0 26565051 57 58 the r e s u l t a n t IFFT sequence i s 59 60 5 2 3 1 46