Digital Signal Processing Sessional: Rajshahi University of Engineering & Technology
Digital Signal Processing Sessional: Rajshahi University of Engineering & Technology
Submitted by:
Md. Mehedi Hasan
Roll:1601118
Section: B
Program 1:Reprentation of basic signals in Matlab
clc
clear all
close all
n = n_lower : n_upper;
x = [n==0];
xlabel('Time in Seconds')
x = [n>=0];
xlabel('Time in Seconds')
x = n.*[n>=0];
xlabel('Time in Seconds')
for i = 1 : (length(r));
y(2*i - 1) = r(i);
y(2*i) = 0;
end
% The upper loop will pad zero to the even positions of matrix y
p2 = audioplayer(r,12000); % Sampling Frequency = 12000
play(p2); %
>> convolution
1 4 10 12 9
1 2 3 0 0
1 2 3 0 0
1 4 10 12 9
Program 6:Code to add two discrete
signals
clc
clear all
close all
% Taking the signals as input from the user
x1 = input('Enter the first signal x1: ');
x2 = input('Enter the second signal x2: ');
n1 = input('No of Elements before zeroth value in x1: ');
n2 = input('No of Elements before zeroth value in x2: ');
% The adding process
Pos_x1 = 0 - n1;
for x = 2:length(x1)
Pos_x1(x) = Pos_x1(x-1) + 1;
end
Pos_x1;
Pos_x2 = 0 - n2;
for xx = 2:length(x2)
Pos_x2(xx) = Pos_x2(xx-1) + 1;
end
Pos_x2;
Pos_y = min(Pos_x2):max(Pos_x1);
if Pos_x1(1)~=Pos_x2(1)
x1_new = [zeros(1,(Pos_x1(1) - Pos_x2(1))) x1];
end
if Pos_x1(1)~=Pos_x2(1)
x2_new = [x2 zeros(1,(Pos_x1(1) - Pos_x2(1)))];
end
%% The output of the addition
disp('The sum of x1 and x2 is given by')
y = x1_new + x2_new
OUTPUT :
y=
6 7 8 -2 -5 0 1 2 3 4 5
Program 7 :Matlab code to read image file
clc
clear all
close all
% Taking the image as input
% RGB Image
img = uigetfile('*', 'Select your image');
x = imread(img);
figure(1)
imshow(x)
% GrayScale Image
x1 = rgb2gray(x);
figure(2)
imshow(x1)
output :