0% found this document useful (0 votes)
14 views5 pages

DSP Exp2

DSP Lab Manual Experiment 2

Uploaded by

tahseens3847
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

DSP Exp2

DSP Lab Manual Experiment 2

Uploaded by

tahseens3847
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Expt 2 : Generating of different signals in both continuous and discrete time domain

Part1. Continuous time domain

clc;
clear;

// 1. Unit Impulse Signal


n_impulse = -10:10;
x_impulse = zeros(1, length(n_impulse));
x_impulse(n_impulse == 0) = 1;

clf
subplot(3, 2, 1);
plot(n_impulse, x_impulse);
title("Unit Impulse Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 2. Unit Step Signal


n_step = -10:10;
x_step = ones(1, length(n_step));

subplot(3, 2, 2);
plot(n_step, x_step);
title("Unit Step Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 3. Unit Ramp Signal


n_ramp = -10:10;
x_ramp = n_ramp .* (n_ramp >= 0);

subplot(3, 2, 3);
plot(n_ramp, x_ramp);
title("Unit Ramp Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 4. Exponential Signal
n_exp = -10:10;
a = 2;
x_exponential = a .^ n_exp;

subplot(3, 2, 4);
plot(n_exp, x_exponential);
title("Exponential Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 5. Square Wave Signal


n_square = 0:0.1:10;
f_square = 1;
x_square = sin(2 * %pi * f_square * n_square);
x_square = sign(x_square);

subplot(3, 2, 5);
plot(n_square, x_square);
title("Square Wave Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid(1);

// 6. Sine Wave Signal


n_sine = 0:0.1:10;
f_sine = 0.1;
x_sine = sin(2 * %pi * f_sine * n_sine);
subplot(3, 2, 6);
plot(n_sine, x_sine);
title("Sine Wave Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid(1);
Part 2 : Discrete time domain

clc;
clear;

// 1. Unit Impulse Signal


n_impulse = -10:10;
x_impulse = zeros(1, length(n_impulse));
x_impulse(n_impulse == 0) = 1;

clf
subplot(3, 2, 1);
plot2d3(n_impulse, x_impulse);
title("Unit Impulse Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 2. Unit Step Signal


n_step = -10:10;
x_step = ones(1, length(n_step));

subplot(3, 2, 2);
plot2d3(n_step, x_step);
title("Unit Step Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 3. Unit Ramp Signal


n_ramp = -10:10;
x_ramp = n_ramp .* (n_ramp >= 0);

subplot(3, 2, 3);
plot2d3(n_ramp, x_ramp);
title("Unit Ramp Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 4. Exponential Signal
n_exp = -10:10;
a = 2;
x_exponential = a .^ n_exp;

subplot(3, 2, 4);
plot2d3(n_exp, x_exponential);
title("Exponential Signal");
xlabel("n");
ylabel("Amplitude");
xgrid(1);

// 5. Square Wave Signal


n_square = 0:0.1:10;
f_square = 1;
x_square = sin(2 * %pi * f_square * n_square);
x_square = sign(x_square);

subplot(3, 2, 5);
plot2d3(n_square, x_square);
title("Square Wave Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid(1);

// 6. Sine Wave Signal


n_sine = 0:0.1:10;
f_sine = 0.1;
x_sine = sin(2 * %pi * f_sine * n_sine);
subplot(3, 2, 6);
plot2d3(n_sine, x_sine);
title("Sine Wave Signal");
xlabel("Time (s)");
ylabel("Amplitude");
xgrid(1);

You might also like