Digital Signal Processing
Experiment 1
GENERATION OF BASIC SIGNALS
(a). Program for the generation of UNIT impulse signal
clc;
close all;
clear all;
t=-2:1:2; % defining time axis and samples
y=[zeros(1,2),ones(1,1),zeros(1,2)] %defining magnitude at different
samples
stem(t,y); %plot discrete signal
xlabel('samples----')
Ylabel(‘magnitude’) % assigning labels to x and y axis
title('unit impulse'); %giving title
n = [-5:5];
imp = zeros(1,length(n));
imp(n==0) = 1;
stem(n,imp) %plot discrete signal
axis([-5 5 -2 2])
xlabel('samples----')
Ylabel(‘magnitude’) % assigning labels to x and y axis
title('unit impulse');
(b) Program for the generation of UNIT step signal
clc;
close all;
clear all;
n=input('enter the n value = ');
t=0:1:n-1;
y= ones(1,n);
stem(t,y);
axis([-5 5 -5 5])
xlabel('samples----')
ylabel('Magnitude')
title('unit step')
(b) Program for the generation of UNIT step signal
clc;
close all;
clear all;
n=[-5:5];
ramp = (n>=0).*n;
stem(n,ramp);
xlabel('samples----')
ylabel('Magnitude')
title('unit ramp');
Ramp signal using for loop
• for n = -4:4
• if n>= 0
• stem(n,n);
• hold on;
• else
• stem(1,0);
• hold on
• end
• end
Generate continuous time sinusoidal signal,
Discrete time cosine signal
clc;
close all;
clear all;
t=0:.01:pi;
y= sin(2*pi*t);
plot(t,y);
ylabel('amp...');
xlabel(‘samples...');
title('sin signal')
Assignment
Q1. Define and Compare C.T.S & D.T.S
Q.2 write a program to generate exponential and cosine signal.
Q.3. Write a program to scale, shift and inversion of various basic signals.
Q.4 write a matlab program to find the current values in the given circuit.
V1 = 20 V V2 = 12 V3 = 40
R1 = 18 R2 = 10 R3 = 16
R3 = 6 R5 = 15 R6 = 8
R7 = 12 R8 = 14
Q.5 Define Stem, Plot, Plot3,fplot, ezplot, linspace, grid,mesh and legend
DSP_EXP. digital signal processing  pptx

DSP_EXP. digital signal processing pptx

  • 1.
  • 2.
    GENERATION OF BASICSIGNALS (a). Program for the generation of UNIT impulse signal clc; close all; clear all; t=-2:1:2; % defining time axis and samples y=[zeros(1,2),ones(1,1),zeros(1,2)] %defining magnitude at different samples stem(t,y); %plot discrete signal xlabel('samples----') Ylabel(‘magnitude’) % assigning labels to x and y axis title('unit impulse'); %giving title
  • 3.
    n = [-5:5]; imp= zeros(1,length(n)); imp(n==0) = 1; stem(n,imp) %plot discrete signal axis([-5 5 -2 2]) xlabel('samples----') Ylabel(‘magnitude’) % assigning labels to x and y axis title('unit impulse');
  • 4.
    (b) Program forthe generation of UNIT step signal clc; close all; clear all; n=input('enter the n value = '); t=0:1:n-1; y= ones(1,n); stem(t,y); axis([-5 5 -5 5]) xlabel('samples----') ylabel('Magnitude') title('unit step')
  • 5.
    (b) Program forthe generation of UNIT step signal clc; close all; clear all; n=[-5:5]; ramp = (n>=0).*n; stem(n,ramp); xlabel('samples----') ylabel('Magnitude') title('unit ramp');
  • 6.
    Ramp signal usingfor loop • for n = -4:4 • if n>= 0 • stem(n,n); • hold on; • else • stem(1,0); • hold on • end • end
  • 7.
    Generate continuous timesinusoidal signal, Discrete time cosine signal clc; close all; clear all; t=0:.01:pi; y= sin(2*pi*t); plot(t,y); ylabel('amp...'); xlabel(‘samples...'); title('sin signal')
  • 8.
    Assignment Q1. Define andCompare C.T.S & D.T.S Q.2 write a program to generate exponential and cosine signal. Q.3. Write a program to scale, shift and inversion of various basic signals. Q.4 write a matlab program to find the current values in the given circuit. V1 = 20 V V2 = 12 V3 = 40 R1 = 18 R2 = 10 R3 = 16 R3 = 6 R5 = 15 R6 = 8 R7 = 12 R8 = 14 Q.5 Define Stem, Plot, Plot3,fplot, ezplot, linspace, grid,mesh and legend