DIGITAL SIGNAL PROCESSING (DSP) LAB MANUAL

EC 453 By RAM NAGESWARA RAO

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING CHALAPATHI INSTITUTE OF ENGINEERING AND TECHNOLOGY (CIET) LAM, GUNTUR - 522034 (AFFILIATED TO ACHARYA NAGARJUNA UNIVERSITY)

LIST OF EXPERIMENTS Experiments Based On Tool Boxes 1. Simulation of AM. 2. Simulation of FM. 3. Simulation of LPF and HPF. 4. Fourier Transforms. 5. Simulation of M-ary PSK. 6. Simulation of DPCM. 7. Evaluation of DFT and IDFT of 16 Sample Sequence using DIT Algorithm. 8. Evaluation of DFT and IDFT of 16 Sample Sequence using DIF Algorithm. 9. Design of IIR Butterworth Filter using Impulse Invariant Method. 10. Design of FIR Filter using Windowing Technique. 11. Convolution of Two Signals. 12. Correlation of Two Signals. 13. DFT Analysis of a Noise Corrupted Signal.

NOTE: A minimum of 10(Ten) experiments have to be performed and recorded by the candidate to attain eligibility for University Practical Examination

SOFTWARE PACKAGE USED : MATLAB version 6.5 TOOL BOXES USED : SIGNAL PROCESING COMMUNICATIONS

REVISION HISTORY

DSP LAB

Page 1

MATLAB stands for MATRIX LABORATORY MATLAB is a software program that allows you to do data manipulation and visualization. MATLAB is a product of MATHWORKS INC. The fact that MATLAB is an interpreted language means that commands to it are parsed and executed as they are entered; there is no need for the compilation /link/run phase.

Starting MATLAB Start  All Programs  Matlab Or Start  run  in dialog box type matlab and press Enter

MATLAB screen when launched

After launching MATLAB set the current working directory to the directory where your programs have to be stored. As seen in the screen shot we have three major sub windows one is command window where we type our commands. Second one is Workspace where we see created variables by us by their name size and type. Third sub window contains history of commands we have used still now. DSP LAB

Page 2

BASIC MATLAB COMMANDS : Command Prompt in MATLAB looks like commands after the prompt and press ENTER

>>

command window. Type your

>> command and Press Enter GETTING HELP >>help command : for getting help for that particular command >>lookfor string : if you don’t have any idea which command for particular operation then just look for how many commands are there related to that operation. This command lists out all commands with the string. Choose appropriate command suitable for our operation Eg : >> lookfor modulation

>>ver >> ls >>cd directoryname >> pwd >>mkdir directoryname >>clc >>clear >>clear variable-name >>exit >>load workspacename >>save workspacename >>who >>whos

: Lists version of MATLAB and its toolboxes : Lists contents of current directory : Changing Directory : Presently Working Directory : create directory by given name directoryname : CLear Command window : Clear all variables – clears allocated space for all variables and this can be seen in workspace also. : to clear particular variable eg: >>clear x : to quit from MATLAB : to load previously stored workspace : store present variables in workspacename : lists all variables : lists all variables with their properties

TOOLBOXES : Collection of Functions written for special applications such as Image Processing, statistics, Control system design, Neural Networks. Each type of functions grouped according to their category. TOOLBOXES used by us mostly are Communication Toolbox and Signal Processing Toolbox apart from common toolboxes such as mathematical toolbox. To get help for these toolboxes type >>help comm

>>help signal

To suppress output of a command from displaying in command window append command with a semi-colon eg : >>a=1:10 will appear in command window as a= 1 2 3 4 5 6 7 8 9 10 >>a=1:10; >> no display here Will do the same job but without any display output to command window To watch some of the demos type >>demos >>sigdemo1 >>sigdemo2 >>phone DSP LAB

Page 3

Basic building block of MATLAB is MATRIX fundamental data type is ARRAY Creating a vector with elements >>x=[1 2 3] x= 1 2 3 x is row vector with 3 elements >>y=[1;2;3] y= 1 2 3 Y is a column vector with 3 elements Accessing particular element in array is just indexing element number >>x(2) >>2

press ENTER % this is nothing but second element of x

Entering a 2*3 matrix >>a=[1 2 3;4 5 6] a= 1 2 3 4 5 6 Entering a 3*3 matrix >> b=[1 2 3;4 5 6;7 8 9] b= 1 2 3 4 5 6 7 8 9 Accessing 2nd row 3rd element >>b(2,3) gives you 5 Appending row or column b=[b y] appends a column b=[b;u] append a row to delete particular row or column >>b(:,3)=[ ] will delete third column >>b(2,:) =[ ] will delete 2nd row of matrix b Here : operator used to give range of rows or columns say if you want to delete only third row to eigth row of a matrix then specify the range as b(3:8 , : ) only : means all columns or rows >>zeros(m,n) gives matrix of m*n wil zeros >>ones(m,n) gives matrix of m*n wil ones >>rand(m,n) generates a matrix of m*n random numbers

DSP LAB

Page 4

Creating Vectors X= initial value : Increment : Final value >>a=1:2:10 a= 1 3 5

7

9

If you do not mention any increment then it will assume by default increment as one (1) >>u=linspace(0,20,5) Will generate 5 elements between 0 and 20 To Print any string on to command window use function display >>display(‘www.RAMNAGRAO.com’) www.RAMNAGRAO.com >>display(a) Will display value of variable a

PLOTTING SIMPLE GRAPHS plot(x,y) : stem(x,y) : xlabel(‘ x- axis name’) : ylabel(‘y –axis name’) : title(‘my plot title’) : clf : figure(n) : hold on : hold off : subplot(m,n,p) : :

plot x Vs y plot x Vs y with stem style discrete points x- axis name in current plot y- axis name in current plot title of the graph clear current figure create new figure window with id number n to draw current plot in the same figure window to draw current plot in the same different window divide figure window into m*n blocks and activate block P for present plot.

PLOT Linear plot.PLOT(X,Y) plots vector Y versus vector X. Plot(var1,var2,’style option’); Style options

Eg to plot x,y in color red and values as stars and in dashed lines then use command as >>plot(x,y,’r*- -‘); DSP LAB

Page 5

MATLAB SCRIPT FILES MATLAB script files are group of instructions arranged inside a file line by line these files have extension as .m ( M- files) after execution of each command in this file output is displayed on to command window. These files are created in MATLAB Editor which is invoked by File New  M-file or by simply type >>EDIT at command window. Creating custom functions Start by opening editor and insert first line as template given below function [output variable] = function_name(input variables); Code related to this function % comments Save this file as same as function_name

Eg :

function [total,interest,duration] = bankamount(p,q,r) This file must be saved by name bankamount.m to run this function >>[t,I,d] =bankamount(1000,8,10);

CONTROL STATEMENTS For loop for m=1:100 num=1/(m+1) end While Loop While i < 100 num=2^I; end IF if I > 4 k=I; elseif (i>20) & (j ==8) k=5*i*j; else k=1; end switch switch flag case value1 block code1; case value2 block code2; otherwise last default block; end

DSP LAB

Page 6

INTERACTIVE INPUT N=input(‘enter the matrix size: ‘); Enter the value of N in command window . until you enter the value program will stop there

IF after any command MATLAB runs into any kind of infinite loop or it hangs then press CTRL+C or CTRL+Z

Save Graphical Result of the Program After generating figure window of a program. Goto FILE  Export in dialog box give name similar to program name and change extension as .jpg

DSP LAB

Page 7

EXPERIMENT 1 : SIMULATION OF AMPLITUDE MODULATION(AM) AIM : Simulation of AM. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications PROGRAM : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AIM

: AMPLITUDE MODULATION SIMULATION

% AUTHOR

: RN RAO

% PARAMETERS: % DATE

: 21 Sep 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t=0:0.001:1;

% time duration of 1 sec and smpling frequency 1000

mesg=sin(2*pi*5*t);

% modulating signal of 5 HZ

subplot(311); plot(t,mesg); title('modulating signal m(t)'); xlabel('

time t ');

ylabel('AMPLITUDE'); carr=sin(2*pi*60*t);

%carrier frequency 60Hz

subplot(312); plot(t,carr); title('Carrier signal c(t)'); xlabel('

time t ');

ylabel('AMPLITUDE'); modsig=amod(mesg,60,1000,'am');

% modulated signal

subplot(313); plot(t,modsig); title('modulated signal s(t)'); xlabel('

time t ');

ylabel('AMPLITUDE'); % Frequency components of modulated signals modsigf=abs(fft(modsig)); f=0:1:511; modsigf=modsigf(1:512); figure(3); stem(f,modsigf); axis([50 70 0 500]); title('frequency components of modulated signals');

DSP LAB

Page 8

xlabel('frequency'); ylabel('amplitude'); figure(2); % demodulation of am signal figure(2); dmodsig=ademod(modsig,60,1000,'am'); subplot(211); plot(t,dmodsig); title('de modulating signal dm(t)'); xlabel('

time t ');

ylabel('AMPLITUDE'); subplot(212); plot(t,dmodsig); hold on plot(t,mesg,'r'); title('modulated and demodulated signals'); xlabel('

time t ');

ylabel('AMPLITUDE'); legend('Demodulated','original')

RESULT :

DSP LAB

Page 9

DSP LAB

Page 10

EXPERIMENT 2 : SIMULATION OF FREQUENCY MODULATION (FM) AIM : Simulation of FM. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %

AIM : Simulation of Frequency Modulation (FM)

% AUTHOR

: RN RAO

% PARAMETERS

:

% DATE

: Sep 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc; clear all; close all; t=0:0.001:1; Fs=1000; Fc=20; x=sin(2*pi*t*5); y=amod(x,Fc,Fs,'fm',5); subplot(311); plot(t,y); hold on; plot(t,x,'r'); grid on; legend('modulated','message'); xlabel('time'); ylabel('amplitude'); title('FREQUENCY MODULATED WAVE'); z=ademod(y,Fc,Fs,'fm',5); subplot(312); plot(t,z); hold on; plot(t,x,'r'); legend('demodulated wave','message'); xlabel('

time');

ylabel('amplitude'); subplot(313); L=length(y); NFFT=2^nextpow2(L);

DSP LAB

Page 11

f=Fs/2*linspace(0,1,NFFT/2+1); Y=fft(y,NFFT)/L; stem(f,2*abs(Y(1:NFFT/2+1))); axis([0 70 0 0.8]); grid MINOR title('spectrum of modulated wave'); xlabel('frequency'); ylabel('amplitude');

RESULT :

DSP LAB

Page 12

EXPERIMENT 3 : SIMULATION OF LPF AND HPF AIM : Simulation of LPF and HPF. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AIM :

Simulation of LPF and HPF

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 21- 09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc; clear all; close all; alphap=input('enter the value of passband ripple= ');

%passband attenuation in db =0.4

alphas=input('enter the value of stopband ripple= ');

%stopband attenuation in db =40

fp=input('enter the value of passband frequency= ');

%passband frequency in hz =200

fs=input('enter the value of stopband frequency= ');

%stopband frequency in hz=700

F=input('enter the value of sampling frequency= ');

%sampling frequency in hz = 2000

omp=2*fp/F; oms=2*fs/F; %TO FIND CUTOFF FREQUENCY & ORDER OF THE FILTER [n,wn]=buttord(omp,oms,alphap,alphas) %SYSTEM FUNCTION OF THE FILTER [b,a]=butter(n,wn) w=0:0.01:pi; [h,om]=freqz(b,a,w,'whole'); m=abs(h); an=angle(h); subplot(211); plot(om/pi,20*log(m)); grid on title(' LPF - Magnitude Response') ylabel('gain in dB'); xlabel('Normalised frequency'); subplot(212); plot(om/pi,an); grid on title(' LPF - Phase Response')

DSP LAB

Page 13

ylabel('phase in radians'); xlabel('Normalised frequency'); %H P F figure(2); [bh,ah]=butter(n,wn,'high') wh=0:0.01:pi; [hh,omh]=freqz(bh,ah,wh,'whole'); mh=abs(hh); anh=angle(hh); subplot(211); plot(omh/pi,20*log(mh)); grid on title(' HPF- Magnitude Response') ylabel('gain in dB'); xlabel('Normalised frequency'); subplot(212); plot(omh/pi,anh); grid on title('HPF - Phase Response') ylabel('phase in radians'); xlabel('Normalised frequency');

RESULTS Input at command prompt enter the value of passband ripple= 0.4 enter the value of stopband ripple= 30 enter the value of passband frequency= 200 enter the value of stopband frequency= 700 enter the value of sampling frequency= 2000 n=

3

wn = 0.3537 b= 0.0736

0.2207

0.2207 0.0736

1.0000 -0.8468

0.5245 -0.0892

a=

bh = 0.3076 -0.9227

0.9227 -0.3076

ah = 1.0000 -0.8468

DSP LAB

0.5245 -0.0892

Page 14

DSP LAB

Page 15

EXPERIMENT 4 : FOURIER TRANSFORM AIM : Simulation of Fourier Transform APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AIM : :

Fourier Transforms.

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 21- 09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %fourier transform of rectangular pulse clc; clear all; close all; Fs=1000; T=1/Fs; L=1000; t=(0:L-1)*T; y=rectpuls(t,200/L); subplot(2,1,1); plot(Fs*t(1:200),y(1:200)); title('rectangular pulse in time domain'); xlabel('time in milliseconds'); ylabel('Amplitude'); NFFT=2^nextpow2(L); y=fft(y,NFFT)/L; f=Fs/2*linspace(0,1,NFFT/2+1); subplot(2,1,2); plot(f,2*abs(y(1:NFFT/2+1))); title('single sided amplitude spectrum of y(t)'); xlabel('frequency hz'); ylabel('|y(f)|'); %Rectangular pulse of less duration y1=rectpuls(t,20/L); figure(2); subplot(2,1,1); plot(Fs*t(1:200),y1(1:200));

DSP LAB

Page 16

title('Rectangular pulse of less width in time domain'); xlabel('time in milliseconds'); NFFT=2^nextpow2(L); y1=fft(y1,NFFT)/L; f=Fs/2*linspace(0,1,NFFT/2+1); subplot(2,1,2); plot(f,2*abs(y1(1:NFFT/2+1))); title('single sided Amplitude spectrum of y(t)'); xlabel('frequency Hz'); ylabel('|y(f)|'); %change in N figure y1=rectpuls(t,20/L); NFFT=64; for i=1:1:4 NFFT=i*NFFT y2=fft(y1,NFFT)/L; f=Fs/2*linspace(0,1,NFFT/2+1); subplot(2,2,i); stem(f,2*abs(y2(1:NFFT/2+1))); title(strcat(' N= ',num2str(NFFT))); end

RESULT :

DSP LAB

Page 17

DSP LAB

Page 18

EXPERIMENT 5 : SIMULATION OF M-ARY PSK AIM : Simulation of M-ary Phase Shift Keying. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AIM : :

Simulation of M-ary PSK.

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 21 - Sep - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc; close all; clear all; m=16; Fd=1

%original msg sample

Fs=3

%modulate signal will be modulated

x=randint(100,1,m);

%random digital signal

y=dmodce(x,Fd,Fs,'PSK',m); % ADD SOME GAUSSIAN NOISE % ynoisy=y+.04*randn(300,1); ynoisy=awgn(y,40); % CREATE SCATTER PLOT FOR NOISE DATA scatterplot(ynoisy,1,0,'b*'); % DEMODULATE z=ddemodce(ynoisy,Fd,Fs,'PSK',m) ser=symerr(x,z) %%check for any symbol error rate [ber,per]=biterr(x,z)

After running once note down the values of ser, ber values change program by removing clear all instruction ( we are operating on same message ) now change value of SNR in AWGN function for every change in SNR run the program and note down the ser,ber values plot SNR vs BER as a graph for that particular m value say 16 Repeat the above process for m=8,4

Observations : DSP LAB

Page 19

For M=16

SNR

For M=4

BER

SNR

BER

RESULT :

DSP LAB

Page 20

EXPERIMENT 6 : SIMULATION OF DPCM AIM : Simulation of Differential Pulse Code Modulation APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AIM : :

Simulation of Differential Pulse Code Modulation

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 21 - 09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc; clear all; close all; predictor=[0 1]; partition=[-1:0.1:0.9]; codebook=[-1:.1:1]; t=[0:pi/50:2*pi]; x=sawtooth(3*t);

% use other wave shapes also

%QUANTIZE WITH DPCM encodedx=dpcmenco(x,codebook,partition,predictor); %RECOVER x FROM MODULATED SIGNAL decodedx=dpcmdeco(encodedx,codebook,predictor); plot(t,x,t,decodedx,'r--'); title('DPCM') legend('original','estimated') distor=sum((x-decodedx).^2)/length(x) msgbox(strcat('Error is ',num2str(distor)));

RESULT

DSP LAB

Page 21

EXPERIMENT 7 : DESIGN OF FIR FILTER USING WINDOWING TECHNIQUE AIM : Design of FIR Filter using Windowing Technique APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications PROGRAM : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AIM : :

Design of FIR Filter using Windowing Technique.

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 14-09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc; clear all; close all; n=20; fp=200; fq=300; fs=1000; fn=2*fp/fs; window=hamming(n+1); %window=rectwin(n+1); stem(window); title(' WINDOW - HAMMING '); xlabel('n'); b=fir1(n,fn,window); [H W]=freqz(b,1,128); figure subplot(211); plot(W/pi,abs(H)); title('magnitude response of lpf'); xlabel('normalised frequency'); ylabel('gain in db'); subplot(212); DSP LAB

Page 22

plot(W/pi,angle(H)); title('phase response of lpf'); xlabel('normalised frequency'); ylabel('angle');

RESULT

DSP LAB

Page 23

EXPERIMENT 8 : CONVOLUTION OF TWO SIGNALS AIM : Convolution of Two Signals. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AIM : :

Convolution of Two Signals.

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 14 -09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc; clear all; close all; %input with square braces and command between elements % x= input('enter the i/p sequence x(n)='); x=[1,0,1,2,-1,3,2]; N1=length(x); n=0:1:N1-1; subplot(221); stem(n,x); title('SIGNAL 1'); xlabel(strcat('x(n)=',num2str(x))); ylabel('x(n)'); %h input ('enter the input sequence h(n)='); h=[1,1,2,2,1,1] N2=length(h); n1=0:1:N2-1; subplot(222); stem(n1,h); xlabel(strcat('h(n)=',num2str(h))); title('SIGNAL 2'); ylabel('h(n)'); y=conv(x,h);

% convolution of two sequences

n2=0:1:N1+N2-2; subplot(212); stem(n2,y); xlabel(strcat('y(n)=',num2str(y))); ylabel('y(n)');title('Convolution of two sequences x(n)& h(n)');

DSP LAB

Page 24

RESULT

DSP LAB

Page 25

EXPERIMENT 9 : CORRELATION OF TWO SIGNALS AIM : Correlation of Two Signals. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % AIM : :

Correlation of Two Signals.

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 14-09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc; clear all; close all; xn=[1,-1,1,1,2] hn=[1,2,1,-1] subplot(311); stem(xn); xlabel('->n'); ylabel('amplitude'); title('sequence x(n)'); subplot(312); stem(hn); xlabel('n'); ylabel('amplitude'); title('sequence h(n)'); rxh=xcorr(xn,hn); subplot(313); stem(rxh); xlabel('->n'); ylabel('amplitude'); title('cross correlation');

DSP LAB

Page 26

RESULT

DSP LAB

Page 27

EXPERIMENT 10 : DFT ANALYSIS OF A NOISE CORRUPTED SIGNAL AIM : DFT Analysis of a Noise Corrupted Signal. APPARATUS & TOOLS : PC with OS windows XP/ 2000 MATLAB 6.1 Tool Boxes – Signal Processing, Communications %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % AIM : :

DFT Analysis of a Noise Corrupted Signal.

% AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 14 -09 - 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clc clear all fsa=2000; t=0:1/fsa:0.1; x=sin(2*pi*200*t); xn=sin(2*pi*200*t)+rand(size(t)); subplot(211); plot(t,x); hold on plot(t,xn,'r--') title(' Signals in Time Domain '); xlabel('time'); ylabel('x(t)'); legend('without noise','with noise') L=length(t); NFFT=2^nextpow2(L); %NEXT POWER OF 2 FROM LENGTH OF 'Y' y=fft(x,NFFT)/L; yn=fft(xn,NFFT)/L; f=fsa/2*linspace(0,1,NFFT/2+1); subplot(212); %PLOT SINGLE - SIDED AMPLITUDE SPECTRUM plot(f,2*abs(y(1:NFFT/2+1))); hold on plot(f,2*abs(yn(1:NFFT/2+1)),'r--'); title('spectrum of Signals without and with Noise'); xlabel('frequency (Hz)'); ylabel('x(f)'); legend('without noise','with noise')

DSP LAB

Page 28

RESULT

DSP LAB

Page 29

MISCELLANEOUS PROGRAMS

DSP LAB

Page 30

TO GENERATE DIFFERENT TYPES OF SIGNALS

Aim: To generate different types of signals EQUIPMENTS: PC with windows (XP/2000), MATLAB Software Program : clc;

%clear command window

close all;

% close all other figures

clear all;

% clear all variables

% unit step sequence N=21;

% number of samples

x=ones(1,N);

% all samples with 1

n=0:1:N-1; subplot(2,2,1);stem(n,x); xlabel('n');ylabel('x(n)'); title('unit step sequence'); % exponential Sequence x1=.8.^(n); subplot(2,2,2),stem(n,x1); xlabel('n'),ylabel('x1(n)'); title('exponential sequence'); %analog sin signal x2=sin(.1*pi*n); subplot(2,2,3);plot(n,x2); xlabel('n');ylabel('x2(n)'); title('analog sin signal'); %disrete sin signal x3=sin(.2*pi*n); subplot(2,2,4);stem(n,x3); xlabel('n');ylabel('x3(n)'); title('discrete sin signal');

DSP LAB

Page 31

RESULT

::

DSP LAB

Page 32

TO GENERATE SUM OF SINUSOIDAL SIGNALS

Aim: To generate sum of sinusoidal signals EQUIPMENTS: PC with windows (XP/2000), MATLAB Software

Program: clc; close all; clear all; t=0:0.05:2*pi; x1=sin(t*5);

%sine wave with period 5

x2=sin(t*9);

%sine wave with period 7

x3=x1+x2;

%sum of x1 and x2

subplot(3,1,1); plot(t,x1) xlabel('time');ylabel('amplitude'); title('sin signal-1'); subplot(3,1,2); plot(t,x2); xlabel('time');ylabel('amplitude'); title('sin signal-2'); subplot(3,1,3); plot(t,x3); xlabel('time');ylabel('amplitude'); title('sum of sin signals');

DSP LAB

Page 33

RESULT

DSP LAB

Page 34

MISCELLANEOUS SIGNAL GENERATION AIM : Miscellaneous Signal Generation t1 = -8:-4; x1 = zeros(size(t1)); t2 = -4:3; x2 = t2+2; t3 = 3:8; x3 = t3-2; t = [t1 t2 t3]; x = [x1 x2 x3]; subplot(221),plot(t,x) xlabel('Time (sec)') ylabel('x(t)') title('a)') % a) t = t+1; subplot(222),plot(t,x) xlabel('Time (sec)') ylabel('x(t)') title('b)') % c) n1 = -6:1; x1 = zeros(size(n1)); n2 = 2:3; x2 = 2*n2-4; n3 = 4:8; x3 = 4-n3; n = [n1 n2 n3]; x = [x1 x2 x3]; subplot(223),stem(n,x) xlabel('n') ylabel('x[n]') title('c)') % d) n = n-1; subplot(224),stem(n,x) xlabel('n') ylabel('x[n]') title('d)'),subplot(111) DSP LAB

Page 35

RESULTS

DSP LAB

Page 36

SINE WAVE GENERATION AIM : SINE WAVE GENERATION t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency fs = 8000; % Sampling Frequency x = sin(2*pi*f/fs*t); % Generate Sine Wave figure(1); stem(t,x,'r'); % View the samples figure(2); stem(t*1/fs*1000,x,'r'); % View the samples hold on; plot(t*1/fs*1000,x); % Plot Sine Wave

DSP LAB

Page 37

AMPLITUDE MODULATION WITHOUT USING TOOLBOX FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

AIM : Amplitude Modulation Without using Toolbox functions. % AUTHOR

: RN RAO

% PARAMETERS : % DATE

: 14 Sep 2012

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %AM without using toolbox clc; clear all; close all; fm=20; fc=500; vm=1;vc=1;interval=0.001; t=0:0.00001:0.09999; f=0:1:99999; m=0.6; wc=2*pi*fc; wm=2*pi*fm; v1=vc*m+vm*sin(wm*t); v2=-(vc*m+vm*sin(wm*t)); vm=vm*sin(wm*t); vc=vc*sin(wc*t); vam=(1+m*sin(wm*t)).*sin(wc*t); vf=abs(fft(vam,10000))/10000; figure; plot(t,vam); hold on; plot(t,v1,'r'); plot(t,v2,'r'); title(' AMPLITUDE MODULATION WITHOUT TOOLBOX ') xlabel('======> Time '); ylabel('======> Amplitude '); figure;

vm=1;vc=1; for mi=1:1:5 m=2*mi/10; v1=vc*m+vm*sin(wm*t); v2=-(vc*m+vm*sin(wm*t));

DSP LAB

Page 38

vam=(1+m*sin(wm*t)).*sin(wc*t); subplot(5,1,mi) plot(t,vam); hold on; plot(t,v1,'r'); plot(t,v2,'r'); ylabel(strcat('m=',num2str(m)));

end

DSP LAB

Page 39

FILTERING FREQUENCY COMPONENTS USING FILTERS

AIM: To Filter Frequency components using LPF & HPF fsa=2000; t=0:1/fsa:0.1; x=sin(2*pi*200*t)+sin(2*pi*600*t)+sin(2*pi*900*t); subplot(211); plot(t,x); title('input to the filter x(t)'); xlabel('time'); ylabel('x(t)'); L=length(t); NFFT=2^nextpow2(L); %NEXT POWER OF 2 FROM LENGTH OF 'Y' y=fft(x,NFFT)/L; f=fsa/2*linspace(0,1,NFFT/2+1); subplot(212); %PLOT SINGLE - SIDED AMPLITUDE SOECTRUM plot(f,2*abs(y(1:NFFT/2+1))); title('spectrum of x(t)'); xlabel('frequency (Hz)'); ylabel('x(f)'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alphap=input('enter the value of passband ripple= ');

%passband attenuation in db

alphas=input('enter the value of stopband ripple= ');

%stopband attenuation in db

fp=input('enter the value of passband frequency= ');

%passband frequency in hz

fs=input('enter the value of stopband frequency= ');

%stopband frequency in hz

F=input('enter the value of sampling frequency= ');

%sampling frequency in hz

omp=2*fp/F; oms=2*fs/F; %TO FIND CUTOFF FREQUENCY & ORDER OF THE FILTER [n,wn]=buttord(omp,oms,alphap,alphas) %SYSTEM FUNCTION OF THE FILTER [b,a]=butter(n,wn) w=0:0.01:pi; [h,om]=freqz(b,a,w,'whole'); m=abs(h); an=angle(h); figure(2); subplot(211); plot(om/pi,20*log(m)); grid on

DSP LAB

Page 40

ylabel('gain in dB'); xlabel('Normalised frequency'); subplot(212); plot(om/pi,an); grid on ylabel('phase in radians'); xlabel('Normalised frequency'); %APPLY FILTER TO THE WAVE yy=filter(b,a,x); figure(3); subplot(211); plot(yy); %legend('filtered') hold on; plot(x,'r'); legend('filtered','original') xlabel('time'); ylabel('amplitude'); title('signals before & after filtering'); subplot(212); L=length(yy); NFFT=2^nextpow2(L); %NEXT POWER OF 2 FROM LENGTH OF 'Y' y=fft(yy,NFFT)/L; f=fsa/2*linspace(0,1,NFFT/2+1); subplot(212); %PLOT SINGLE - SIDED AMPLITUDE SOECTRUM plot(f,2*abs(y(1:NFFT/2+1))); title('spectrum of filtered signal'); xlabel('frequency (Hz)'); ylabel('magnitude'); INPUT AT COMMAND PROMPT enter the value of passband ripple= 0.2 enter the value of stopband ripple= 30 enter the value of passband frequency= 200 enter the value of stopband frequency= 500 enter the value of sampling frequency= 2000 press enter n = 5 , wn = 0.2958 b=

0.0065

a=

1.0000 -2.0177

DSP LAB

0.0327

0.0655

0.0655

2.0732 -1.1455

0.0327

0.0065

0.3423 -0.0428

Page 41

DSP LAB

Page 42

DSP LAB

Page 43

EC 453 DSP LAB

LAB MANUAL. EC 453. By. RAM NAGESWARA RAO. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING. CHALAPATHI INSTITUTE OF ... DSP LAB. Page 2. MATLAB stands for MATRIX LABORATORY. MATLAB is a software program that allows you to do data manipulation and visualization.

3MB Sizes 2 Downloads 174 Views

Recommend Documents

EC-6512-CS-Lab-Manual- By EasyEngineering.net.pdf
Page 1 of 52. **Note: Other Websites/Blogs Owners Please do not Copy (or) Republish. this Materials, Students & Graduates if You Find the Same Materials with.

214-453-1-SM.pdf
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. 214-453-1-SM.pdf. 214-453-1-SM.pdf. Open. Extract. Open with.Missing:

AP-453.pdf
Small Packet Traffic Performance. Optimization for. 8255x and 8254x ... A1. A1ft. 1. λ. − λ. 6 (i) m = 4. equation of line is 3 9. ln 39. − ... correct expression for lny. (iii) Substitutes y and rearrange for 3x. Solve 3x. = 1.150. x = 0.127.

Nba2k17 Codes Ps4 453
Xbox One News & Rumors N4G. NBA 2K12 Cheats - PlayStation 2 Cheats: ... codes, Easter eggs, tips, and other ... Apple TV, Free Game Generator Codes Nba2k17 Vc Generator Android Phones Code Generator Nba2k17 Vc Generator 2K16 Live. Free Game Generator

453-1218-1-EDf.pdf
Some procedures that were adopted as bibliographic surveys, mapping, satellite image. analysis and measurement parameters, indicated that at the Ceará ...

AHEAD EC Levelling Layer
AHEAD EC Levelling Layer will, when applied on Zebra Anode, act as an alkaline ... 2-3 hours. No. of coats required on ZEBRA normally one coat at 1 mm ...

COMPUTATIONAL ACCURACY IN DSP IMPLEMENTATION ...
... more logic gates are required to implement floating-point. operations. Page 3 of 13. COMPUTATIONAL ACCURACY IN DSP IMPLEMENTATION NOTES1.pdf.

EC counter affidavit.pdf
file/deliver an affidavit in Form 26, under Section 33-A of the. Representation of the People Act, 1951 read with Rule 4-A of the. Conduct of Elections Rules, 1961, is to enable the voters/electors. af lha aanaarnaA nnnofifr rannrr tn ennrice thcmsel

CBF Comments_Senate_PA House Bill 453.pdf
Sincerely,. Harry Campbell, Pennsylvania Executive Director. Chesapeake Bay Foundation. Page 1 of 1. CBF Comments_Senate_PA House Bill 453.pdf.

EC-1992.pdf
PART – A. 1.1 Relative to a given fixed tree of a network, ... R. u t. R R+. (d) ( ) 1 1. 1. 2. 1 2. 1 . R R C e u t. R R. −. +. +. −. V. + − + −. V R VL. V C .... EC-1992.pdf.

EC Tatarstan - SCORE.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. EC Tatarstan ...

EC - Original Registration.pdf
Page 1 of 5. Division of Professions and Occupations. Office of Licensing—Electrical. 1560 Broadway, Suite 1350. Denver, CO 80202. (303) 894-7800 / Fax (303) 894-7693. www.colorado.gov/dora/Electrical. Application for Original Registration. ELECTRI

EC 10.pdf
Rédacteur en chef : Régis MALET. Co-rédacteurs en chef adjoints : Juergen SCHRIEWER, José Luis WOLFS. Secrétariat de rédaction : Marie-Lise LORTHIOIS.

EC 320 syllabus.pdf
Boston University Department of Economics. 3. Outline of Course Topics and Reading. 1. Introduction and Overview, or Why Economic Development is the Heart ...

DSP ALGORITHMS AND ARCHITECTURE.pdf
b) Describe with examples sampling period reduction and parallel processing in. applications of unfolding. 10. 8. a) Describe with an example any one shortest ...

DSP Project 2 Report
Compare Matrix Form FFT with Matlab Functions . ...... but the Maple computer algebra system for example returns ?1 for this. % values so this function returns -1 ...

CBI-Recruitment-DSP-Vacancies-Notification-Application.pdf ...
Retrying... CBI-Recruitment-DSP-Vacancies-Notification-Application.pdf. CBI-Recruitment-DSP-Vacancies-Notification-Application.pdf. Open. Extract. Open with.

NIRDESH DSP FINAL for Publish.pdf
... sl ds mi;ksx gsrq fuEukuqlkj lkQ~Vos;j. vko';d gS rFkk vius flLVe dh fuEukuqlkj lsfVaXl fd;s tkus dk. d"V djsaA. Minimum Requirement. window – XP, Window 7, or Window -10. Ms office – 2007, 2010. For System setting please follow this step. 1-

DSP ALGORITHMS AND ARCHITECTURE.pdf
Page 2 of 2. JUP – 153. 6. a) Compute circular convolution using DITFFT algorithms for. x (n) (n) (n 1) 2 (n 3) 1 = δ + δ − + δ − and. x2(n) = u(n) – u(n – 3). 10.

DSP Project 3 Report
Because of this, the bilinear z-transform is well suited to the task of converting classic analog filter into a digital IIR model which preserves the shape of the magnitude frequency response of the parent analog system. 3.5.2 Design of Digital Filte

DSP ALGORITHMS AND ARCHITECTURE.pdf
[PDF.41HDL] Free Download : Forbidden Fruit ... Fruit Anonymous by JosefinaHogan - issuu... Forbidden ... doc: Forbidden Fruit (1898) - Horntip read online.

Implementing DSP Algorithms with On-Chip Networks
with high communication complexity, it is natural to use a. Network-on-Chip (NoC) to implement the communication. We address two key optimization problems ...