0% found this document useful (0 votes)
24 views

DSP Lab File

DSP LAB FILE

Uploaded by

mdshahnawaz1639
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
24 views

DSP Lab File

DSP LAB FILE

Uploaded by

mdshahnawaz1639
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
digital Signal Processing Lab Name: Khushi Ranj Trade: GEC-29 Registration No.: 2130573 Institute: Sant Longowal Institute of Engineering and Technology Teacher In-char; “Alka Singla INDEX SL] Name of the Document [Page [Date of | Date of, | No no. | exp. | ale a [3-s UJor hs ENS > Ht ]e9 25) (1. | Introduction to MATLAB . | Generation of Discrete Time Signal \ "3 | Shifting of Signals po 19 )03/x3 | \ + | Verification of Sampling Theorem both ] in time and frequency domains, 5S. | Linear Convolution of two given sequences 6. Circular Convolution of two given __Sequences using summation formula Linear convolution from circular ‘convolution with zero padding —__ a 8. Linear and Circular Convolution by DFT land IDFT method ___ fee; [Po-?* Exp No. D0! Signa! Processing tb . ate POPC TS es To implement LP FIR filter for a given sequence |? a2 oF g Wt Ee —_[To implement HP FIR filter fora given sequence |r-34 Zo. M2 7 uy LC LE 1.Introduction to MATLAB AIM: To get familiarise with basic elements of MATLAB, MATLAB windows and general commands APPARATUS REQUIRED: Software used: Matlab Online THEORY: MATLAB stands for Matrin Laboratory is fourth generation high level programming language and interactive environment for numerical computation, visualization and programming. Desktop-basics: Desktop includes these panels: ~ Current Folder: for accessing file. ~ Command Window: Enter commands at the command line, indicated by the prompt. &) Workspace: Explore data that you create import files. As you work in MATLAB, you issue commands that create variable and call functions. For eg.- Create a variable named by typing this statement ast Matlab adds variable ‘a’ to the workspace and displays the result in the command 2 " Exp No. Date: emo. Digital Signal Processing Lob . ote: PCEC-713 Example Cod clear all X= input("Enter these numbers"); SE((1)> x(3) && x(1) > X(2)) {printf ("%d is the largest number", x(1)) else if x (2) > x(3) && x(2) > x(1) fprintf ("9d is the largest number", x(2)) else fprinti("96d is the largest number", x(3)) end , Input: Enter there numbers. 123 Output: 3 is the largest number ‘Types of Files: There are of files in MATLAB three different types (2) M.files (2) MAT. Files (3) MEX. files Milles: These are standard ASCII text files with a (.m) extension to the file name. Any Program written ina MATLAB editor is saved as mJfiles, Manfiles: It provides access to any data you saved. Opening the file starts the import wizard to load the data into the matlab workspace, mexcfiles: It controls compiled executable code that exten some manner. ids MATLAB functionality in You execute these files just as you would write script program. The original code is written in either FORTRAM or C++ and compiled for a specific platform, MATLAB commands: MATLAB commands for managing a session, Variable: You can create new variable in the works pace by running MATLAB Code or RARE enter existing variables. To create new variable enter the variable name in the Command window, followed by an equal sign (=) and the value you want to assign to the variable. Ex: >>> ast pe B osotot sional Processing tab : PCEC-713 ‘Command Purpose la —~*+| clears command window exist check for existence of variables global declare variable to the global Took for ‘Search for a Key word quit ‘stops MATLAB, PRECAUTIONS: 1. fix problems in code 2. View code analyzer messages 3. Check code for errors and warnings using the code analogy. 4. Enable continuous code checking RESULT: We have got familiar with the basic elements of MATLAB, Exp Mo. Date: AIM: Digital Signal Processing Lab : Exp No, PCEC TIS Date: 2.Generation of Discrete Time Signal ~ ‘To generate a discrete time signal sequence (Impulse, Unit Step, Ramp, Exponential, Sine, Cosine, Rising and decaying exponential) using MATLAB function APPARATUS REQUIRED: © Software- MATLAB THEORY: In signal processing experiments, we need the help of some fundamental signals such as impulse, unit step, ramp wave, exponential wave, sine wave, cosine wave, etc. A digital signal can be either a deterministic signal that can be predicted with certainity, or a random signal that is unpredictable. Due to ease in signal generation and need for predictability, deterministic signal can be used for system simulation studies. Standard forms of some deterministic signals that are frequently used in DSP are discussed below: . Impulse: The simplest signal is the unit impulse signal which is defined as, 6(n)=1forn=0 =Ofornz0 . Step: The general form of step function is, u(n} fornz0 =O forn<0 |. Ramp: This signal is given by, r(n)=nfornz0 =Oforn<0 . Exponential: The decaying exponential is a basic signal in DSP whose general formis, x(n) =anforalln. . Sine: A sinusoidal sequence is defined as, x(n) = sin(n) . Cosine: A cosine sequence is defined as, x(n) = cos(a) . Rising exponential: A rising exponential is given by, . . . © Digital Signol Processing Lob, : Exp Na, Digito! Signo! Processing Lob, fp h PCEC-713 8. Decaying exponenti; A decaying exponential is given by, PROCEDURE: 1. Start the MATLAB program. 2. Open new M-file 3. Typethe program 4, Save in current directory S. Compile and Run the program 6. Ifany error occurs in the program correct the error and run it again 7 8. . For the output see command window\ Figure window Stop the program. . PROGRAM & OUTPUT: delta =(n ‘stem(n, delta); title(Impulse Signal’); xlabel(‘n’); ylabel(‘Amplitude’); Unit Step Signal: = -10:10; u=(n>=0); stem(n, u); tide(Unit Step Signal’); xlabel(n); ylabel( Amplitude’); Degital Signal Processing Lab, PCECT13 . fap to. ote: Ramp Signal: n=-10:10; rent (n>=0): stem(n.r): title(‘Ramp Signal’); sdabel('n}; ylabel( Amplitude’); Exponential Signal: n=-10:10; alpha = 05: x=alpha*n: stem(n. x}: utle( Exponential Signal’): xtabel('n'): ylabel( Amplitude’); ‘Sine Signal n= 0:01:10; fel xesin(2pta): plor{n, x): dithe(Sine Signal}; {Le DPBS Spe Marreny Lod - ae Ntabel( Time’) vladei(Amplirade’}; Cosine Signal (Similar to the sine signal): R= OML10: fei; | xe cos(? pitta): Plog{a x): te(Casine Signal): i wiabel( Time): siabel[ Amplitude): Decaying Exponential Signal (Sisnilar to the exponential signal): neeaiie aipha = OS: a ep(aipha* a} Digital Signa! Processing tab . Exp No... Pac TA3 Date: plor(n, x): tide(Decaying Exponential Signal’ xtabel( Time’); ylabel Amplitude’); RESULT: Thus the MATLAB programs for functional sequence of a signal (Impulse, Unit Step, Ramp, Exponential, Sine, Cosine. Rising and Decaying exponential) using MATLAB fonction written and the results were plotted \ Digitol Signal Processing Lob. : Expo. . PCEC-713 Date: 3, Shifting of Signals AIM: Write a program in MATLAB to generate and plot the sequences: (shifted signals) over the indicated interval. APPARATUS REQUIRED: Software: MATLAB . THEORY: Shifting signals in MATLAB typically involves changing the time or frequency axis of a signal to create a new version of the signal that is shifted in time or frequency. This can bbe useful in various signal processing and communication applications. ‘Time shifting involves moving a signal along the time axis. Suppose you have a signal x(t), and you want to create a shifted version of x.shifted(t), delayed by a certain amount of tine T seconds. The basic theory Involves applying a time shift operation as follows: xshifted(t) = x{t-T) Sequences given are: 1 x(n)=25(n¢2)- 6(n-4), -5=n0) 3 SU end Problem1 Code: MATLAB Dawelprotiern | m ~ _ ee 1 } Xproblemi:2*impulse(n42)-impulse(n-4) 2 q Kusing impulse function 3 4 Ly1,n1}=impseq(-2,-5,5)5 s [y2,n2]}=impseq(4,-5,5)5 6 ye2*yl-y2; 7 | neni; & sten(n,y, filled’, black’); 3 | xlabel(‘n*);] 18 ylabel(*x(n)")5 wn title("1. output’); 12 grid on; 13 | print("-clipboard" ,*-dmeta’) i i . Digital Signal Processing Lob, . fp Wo PEC TY bate Problem? Code: MATLAD Deweppnatiern? m [I Xprobhem2:x(ny=n(u(n)-u(n-10)) +10%exp(-0.3(-10))" (uln-A8) ule 2)) 2 2b ausing untt step function 3 | nto; 4 | n2e20; 5 nemdinds 6 | xden. *(unttstepfun(O,nt,n2)-unitstapfun(1a,ni402))5 7 | xze20%exp(-0..3*(n-10)) 4 s | xSeunit stepfun(10,n1,n2) -unitatepfun(20,n1,n2)5 ° yenten2 x33 10 | stem(nsy, Filled, “black"): 21 | xlabel(*n* a2 | ylabel(‘x(n)"), a | title("2. output 24 | grid on; 35 | print (clipboard *-daeta") Problem 3 Code: BETAS Oweprstiend m : i Zx(n)ecos(0.O4nn)10.2u(n), O¢ence50 where w(n) 15 @ Gaussian Random 2 Xsequence with zero mean end unit variance 3 | 5 | itn) 40, 2*randn(size(m)); 6 7 | title( “Sequence tn Problem 3° 2 xlabel ('n"); 9 | ylabel (x(n) D5 No. “_pigital Signal Processing lab. . nae Date: PCEC-713 Sequence In Problem 3 RESULT: ‘The sequences over the indicated interval are shifted and plotted. va

You might also like