DSP Practical File Harshit
DSP Practical File Harshit
ICT 391
Submitted By –
Submitted To -
Harshit Kumar CS
Rai Sir
01316412822
B.Tech ECE 5th Sem
INDEX
u = double(t >= 0); % u(t) = 0 for t < 0 and u(t) = 1 for t >= 0
delta = zeros(size(t));
figure;
xlabel('t');
ylabel('u(t)');
grid on;
xlabel('t');
ylabel('\delta(t)');
axis([-5 5 0 120]);
grid on;
xlabel('t');
ylabel('r(t)');
axis([-5 5 -1 6]);
grid on;
Output
Program 2
y = conv(x, h);
figure;
subplot(2,1,1);
title('Signal x[n]');
xlabel('n');
ylabel('x[n]');
grid on;
subplot(2,1,2);
title('Signal h[n]');
xlabel('n');
ylabel('h[n]');
grid on;
figure;
xlabel('n');
ylabel('y[n]');
grid on;
Output
Program 3
X_omega = zeros(size(omega));
for k = 1:length(omega)
end
figure;
% Magnitude plot
subplot(2,1,1);
title('Magnitude of DTFT');
xlabel('\omega (rad/sample)');
ylabel('|X(\omega)|');
grid on;
% Phase plot
subplot(2,1,2);
title('Phase of DTFT');
xlabel('\omega (rad/sample)');
grid on;
Output
Program 4
N = length(x);
for k = 1:N
end
figure;
% Magnitude plot
subplot(2,1,1);
title('Magnitude of DFT');
xlabel('k');
ylabel('|X[k]|');
grid on;
% Phase plot
subplot(2,1,2);
title('Phase of DFT');
xlabel('k');
grid on;
Output
Program 5
X_fft = fft(x);
figure;
subplot(2,1,1);
xlabel('k');
ylabel('|X[k]|');
grid on;
subplot(2,1,2);
xlabel('k');
ylabel('Angle of X[k] (radians)');
grid on;
Output
Program 6
N = length(x);
for n = 1:N
for m = 1:N
end
end
figure;
subplot(3,1,1);
stem(0:N-1, x, 'filled');
title('Sequence x[n]');
xlabel('n');
ylabel('x[n]');
subplot(3,1,2);
stem(0:N-1, h, 'filled');
xlabel('n');
ylabel('h[n]');
subplot(3,1,3);
xlabel('n');
ylabel('y[n]');
grid on;
Output
Program With cconv Function
% Define two input sequences x[n] and h[n]
% Plot the input sequences and their circular convolution result using cconv
figure;
subplot(3,1,1);
stem(0:length(x)-1, x, 'filled');
title('Sequence x[n]');
xlabel('n');
ylabel('x[n]');
subplot(3,1,2);
stem(0:length(h)-1, h, 'filled');
xlabel('n');
ylabel('h[n]');
subplot(3,1,3);
xlabel('n');
ylabel('y[n]');
grid on;
Output
Program 7
N = length(x);
X_z = zeros(size(Z));
for n = 1:N
end
figure;
subplot(1,2,1);
xlabel('Re(z)');
ylabel('Im(z)');
zlabel('|X(z)|');
colorbar;
subplot(1,2,2);
xlabel('Re(z)');
ylabel('Im(z)');
colorbar;
syms n z;
X_z = 0;
for n = 1:length(x)
end
disp(X_z);
% Plot the Z-plane
figure;
zplane(b, a);
Output
Program 8
Aim – To design low pass butterworth filter
Program
% Define filter parameters
N = 4; % Filter order
Wn = fc / (fs / 2);
figure;
subplot(2,1,1);
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
subplot(2,1,2);
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
grid on;
Output