DSP Task-1: Name: D.Satya Varma REG NO: 18BEC0549 Code

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

DSP TASK-1

NAME: D.SATYA VARMA


REG NO: 18BEC0549

CODE:
clc
clear all; %#ok<*CLALL>
close all;
n = -100:1:100;
imp =(zeros(size(n)));
imp(n==0) = 1;
figure('position',[100,100,600,400])
stem(n, imp, 'markersize',
6, 'markerfacecolor', 'g', 'markeredgecolor', 'k')
xlabel('Discrete Time')
ylabel('Amplitude')
title('Delta Signal')
axis([-10 10 -1 2])

Published with MATLAB® R2020a


1
%Generation of Unit step signal
clc
clear all; %#ok<*CLALL>
close all;
n = -100:1:100;
imp =(zeros(size(n)));
imp(n>=0) = 1;
figure('position',[100,100,600,400])
stem(n, imp, 'markersize',
6, 'markerfacecolor', 'g', 'markeredgecolor', 'k')
xlabel('Discrete Time')
ylabel('Amplitude')
title('Step Signal')
axis([-10 10 -1 2])

Published with MATLAB® R2020a

1
%Generation of Ramp Signal
clc
clear all;
close all;
n = -10:10;
rmp = zeros(size(n));
rmp(n>=0) = n(n>=0) +1;
stem(n, rmp, 'markersize',
6, 'markerfacecolor', 'g', 'markeredgecolor', 'k')
xlabel('Discrete Time')
ylabel('Amplitude')
title('Ramp Signal')
axis([-10 10 -10 10])

Published with MATLAB® R2020a

1
%Generation of exponential signal
clear all %#ok
close all
clc
a = 0.5;
n = -10:10;
x = a.^n;
stem(n,x,'markersize',
6, 'markeredgecolor', 'b', 'markerfacecolor', 'r');

Published with MATLAB® R2020a

1
%Generation of white noise – using Gaussian Random Variable
clc
clear all; %#ok
close all;
n = -1000:1000;
x = rand(size(n));
x = 100*x;
figure
stem(n,x, 'markerfacecolor', 'r', 'markeredgecolor', 'b', 'markersize',
6);
hold on
axis([-100 100 -100 100])
n = n+0.5;
y = -100*rand(size(n));
stem(n,y,'markersize',
6, 'markeredgecolor', 'b', 'markerfacecolor', 'r');
title('Random generated noise')
hold off;

Published with MATLAB® R2020a

1
%Generation of random noise using gaussian random variable and
processing
clc
clear all %#ok<*CLALL>
close all
n = -10:10;
x = 0.5.^n;
noise = 100*rand(size(x));
xwn = x+noise;
%adding noise with amplification of 100 since noise is between 0 and 1
plot(n,x);
hold on
plot(n,xwn);
noise_f = [noise,0,0];
noise_g = [0,noise,0];
noise_h = [0,0,noise];
noise_sub = noise_f+noise_g+noise_h;
noise_sub = noise_sub/3;
noise_sub=noise_sub(2:22);
y = xwn-noise_sub; plot(n,y);
hold off;
legend('Signal','signal with noise', 'Signal after smoothing');
title('Noise')

Published with MATLAB® R2020a

You might also like