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

Digital Signal Processing Lab File: Experiment-1

- The document contains details of 10 experiments conducted on digital signal processing using Scilab. - The experiments generate and analyze common digital signals like unit step, ramp, exponential and sine waves. - Operations like shifting, linear convolution, DFT and IDFT are also demonstrated on various sequences.

Uploaded by

Parshant
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Digital Signal Processing Lab File: Experiment-1

- The document contains details of 10 experiments conducted on digital signal processing using Scilab. - The experiments generate and analyze common digital signals like unit step, ramp, exponential and sine waves. - Operations like shifting, linear convolution, DFT and IDFT are also demonstrated on various sequences.

Uploaded by

Parshant
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

DIGITAL SIGNAL

PROCESSING LAB FILE


NAME- PARSHANT SHARMA
ROLL NUMBER – SG19530
CLASS – ECE 5th SEMESTER
COLLEGE – PUSSGRC

EXPERIMENT-1
AIM: To generate Unit step sequence generation
APPARATUS REQUIRED: Personal Computer having Scilab installed on it.
THEORY:

CODE ON SCILAB :

--> clear;
--> clc;
--> t = -6:0.01:6;
--> u = ones ( t ) .*( t >=0) ;
--> plot (t , u ) ;
--> xgrid (4 ,1 ,7) ;
--> xlabel t fontsize 4 ;
--> ylabel u(t) fontsize 4;
--> title Unitstep fontsize 4;
--> set (gca() ,"data_bounds" ,matrix ([ -6 ,6 , -0.1 ,1.1] ,2 , -1))

RESULT:
EXPERIMENT-2
AIM: To generate Unit ramp sequence generation
Apparatus required: Personal Computer having Scilab installed on it
THEORY:
CODE IN SCILAB :

--> clear;
--> clc;
--> t = -6:0.01:6;
--> r = t .*( t >=0) ;
--> plot (t , r ) ;
--> xgrid (4 ,1 ,7) ;
--> xlabel t fontsize 4;
--> ylabel r(t) fontsize 4;
--> title Ramp fontsize 4;
--> set (gca() ,"data_bounds" ,matrix ([ -6 ,6 , -0.1 ,7] ,2 , -1));

RESULT:
EXPERIMENT-3
AIM: To generate Unit sample sequence
APPARATUS REQUIRED: Personal Computer having Scilab installed on it
THEORY:
CODE IN SCILAB :

--> clear;
--> clc;
--> close;
--> L = 4;
--> n = -L:L;
--> x = [zeros(1,L),1,zeros(1,L)];
--> b = gca();
--> b.y_location = "middle";
--> plot2d3('gnn',n,x)
--> a=gce();
--> a.children(1).thickness =4;
--> xtitle('Graphical Representation of Unit Sample Sequence','n','x[n]');
RESULT:
EXPERIME0NT-4
AIM: To generate Discrete ramp sequence
APPARATUS REQUIRED: Personal Computer having Scilab installed on it
THEORY:

CODE IN SCILAB:
--> clear;
--> clc;
--> close;
--> L = 4; --> n = -L:L;
--> x = [zeros(1,L),0:L];
--> b = gca();
--> b.y_location = 'middle';
--> plot2d3('gnn',n,x)
--> a=gce();
--> a.children(1).thickness =2;
--> xtitle('Graphical Representation of Discrete Unit Ramp Sequence','n','x[n]');
RESULT:
EXPERIMENT-5
AIM: Graphical Representation of Exponential Decreasing Signal
APPARATUS REQUIRED: Personal computer with Scilab installed in it.
THEORY:
Exponential Decreasing Function

CODE ON SCILAB:
--> clear;
--> clc;
--> close;
--> n = 0:10;
--> a =0.5;
--> x = (a)^n;
--> a=gca();
--> a.thickness = 2;
--> a.x_location = "origin";
--> plot2d3('gnn',n,x);
--> xtitle('Graphical Representation of Exponential Decreasing Signal','n','x[n]');
RESULT:

EXPERIMENT-6
AIM: To do Linear Convolution of two sequences
APPARATUS REQUIRED: Personal Computer loaded with Scilab in it
THEORY:
CODE IN SCILAB:
--> clear all;
--> clc;
--> x = [1,2,1,1];
--> N1=length(x);
--> h=[1,1,2,1];
--> N2=length(h);
--> N=N1+N2-1;
--> y=zeros(1,N);
--> for i = N1+1:N
> h(i) = 0;
> end;
--> for i = N2+1:N
> x(i) = 0;
> end;
--> for n = 1:N
> for k = 1:N
> if(n >= k)
> y(n) = y(n)+x(n-k+1)*h(k);
> end;
> end;
> end;
--> disp(y, "Linear Convolution Result is = ")
RESULT:
"Linear Convolution Result is = "
1. 3. 5. 7. 5. 3. 1.

EXPERIMENT-7
AIM: To generate Single Sine waveform
APPARATUS REQUIRED: Personal Computer loaded with Scilab
THEORY:
SIGNLE SINE WAVEFORM

CODE ON SCILAB:
--> n = 0:99;
--> y = sin(2*%pi*n/100);
--> plot(y);
RESULT:

EXPERIMENT-8
AIM: Circular convolution of x1 [ n ] = [ 0 , 1 , 2 , 3 , 4 ] and x2 [ n ] = [ 0 , 1 , 0 , 0 , 0 ]
APPARATUS REQUIRED: Personal Computer loaded with Scilab
THEORY:
CODE IN SCILAB:
--> clear ;
--> clc ;
--> close ;
--> x1 =[0 ,1 ,2 ,3 ,4];
--> x2 =[0 ,1 ,0 ,0 ,0];
--> X1 = fft ( x1 , -1) ;
--> X2 = fft ( x2 , -1) ;
--> Y = X1 .* X2 ;
--> y = round ( fft (Y ,1) ) ;
--> disp (y);
RESULT:
4. 0. 1. 2. 3.

EXPERIMENT-9
AIM: To do Shifting of Discrete time signal
Apparatus Required: Personal Computer loaded with Scilab
THEORY:
CODE ON SCILAB:
--> clc ;
--> clear ;
--> close ;
--> x=input("Enter the input sequence:= ");
--> m = length ( x ) ;
--> lx = input ("Enter the starting point of original signal:= ");
--> hx = lx +m -1;
--> n = lx :1: hx ;
--> subplot (3 ,1 ,1);
--> a = gca () ;
--> a.x_location="origin";
--> a.y_location="origin";
--> a.data_bounds=[-10,0;10,10];
--> plot2d3('gnn',n,x);
--> xlabel('n===>');
--> ylabel('Amplitdue --->')
--> title("Original Sequence");
--> d=input("Enter the delay:= ");
--> n=lx+d:1:hx+d;
--> subplot(3,1,2)
--> a=gca();
--> a.x_location="origin";
--> a.y_location ="origin";
--> a.data_bounds=[-10,0;10,10];
--> plot2d3('gnn',n,x)
--> xlabel('n===>')
--> ylabel("Amplitude --->");
--> title("Delayed Sequence");
--> a=input("Enter the advance:= ");
--> n=lx-a:1:hx-a;
--> subplot(3,1,3);
--> a=gca();
--> a.x_location="origin";
--> a.y_location="origin";
--> a.data_bounds=[-10,0;10,10];
--> plot2d3('gnn',n,x);
--> xlabel('n===>');
--> ylabel("Amplitude--->");
--> title("Advanced Sequence")

RESULT:

Enter the input sequence:= [1,2,3,4,5]


Enter the starting point of original signal:= 0
Enter the delay:= 2
Enter the advance:= 3
EXPERIMENT-10
AIM: To find DFT and IDFT of given sequence
Apparatus required: Personal Computer loaded with Scilab
THEORY:

CODE ON SCILAB:

--> clc;
--> close;
--> clear;
--> xn = input("Enter the real input discrete sequence x[n]=");
--> N = length(xn);
--> XK = zeros(1,N);
--> IXK = zeros(1,N);
//Code block to find the DFT of the Sequence
--> for K = 0:N-1
> for n = 0:N-1
> XK(K+1) = XK(K+1)+xn(n+1)*exp(-%i*2*%pi*K*n/N);
> end
> end
--> [phase,db] = phasemag(XK)
--> [phase,db] = phasemag(XK);
--> disp(XK,'Discrete Fourier Transform X(k)=');
--> disp(abs(XK),'Magnitude Spectral Samples=');
--> disp(phase,'Phase Spectral Samples=');
--> n = 0:N-1;
--> K = 0:N-1;
--> subplot(2,2,1);
--> a = gca();
--> a.x_location = "origin";
--> a.y_location = "origin";
--> plot2d3('gnn',n,xn);
--> xlabel('Time Index n---->');
--> ylabel('Amplitude xn---->');
--> title('Discrete Input Sequence');
--> subplot(2,2,2);
--> a = gca();
--> a.x_location = "origin";
--> a.y_location = "origin";
--> plot2d3('gnn',K,abs(XK));
--> xlabel('Frequency Sample Index K---->');
--> ylabel('|X(K)|---->');
--> title('Magnitude Spectrum');
--> subplot(2,2,3);
--> a = gca();;
--> a.x_location = "origin";
--> a.y_location = "origin";
--> plot2d3('gnn',K,phase);
--> xlabel('Frequency Sample Index K---->');
--> ylabel('<X(K) in radians---->');
--> title('Phase Spectrum');
--> //Code block to find the IDFT of the sequence
--> for n = 0:N-1
> for K = 0:N-1
> IXK(n+1) = IXK(n+1)+XK(K+1)*exp(%i*2*%pi*K*n/N);
> end;
> end;

--> IXK = IXK/N;


--> ixn = real(IXK);
--> subplot(2,2,4);
--> a = gca();
--> a.x_location = "origin";
--> a.y_location = "origin";
--> plot2d3('gnn',[0:N-1],ixn);
--> xlabel('Discrete Time Index n ---->');
--> ylabel('Amplitude x[n]---->')
--> title('IDFT sequence');

RESULT:

Enter the real input discrete sequence x[n]=[1,2,1,2,3,0]


phase =
0. -180. -90. 3.817D-14 90. 180.
db =
19.08485 6.0205999 10.791812 0. 10.791812 6.0205999
"Discrete Fourier Transform X(k)="
column 1 to 3
9. + 0.i -2. - 8.882D-16i 2.220D-15 - 3.4641016i
column 4 to 6
1. + 7.348D-16i -4.663D-15 + 3.4641016i -2. - 4.441D-15i
"Magnitude Spectral Samples="
9. 2. 3.4641016 1. 3.4641016 2.
"Phase Spectral Samples="
0. -180. -90. 3.817D-14 90. 180.

You might also like