DSP_Assignment_merged
DSP_Assignment_merged
5z−1)
syms z omega
disp(' ');
disp('---------------------------------');
disp('---------------------------------');
end
% Plot magnitude and phase response
figure;
subplot(2,1,1);
title('Magnitude Response');
xlabel('Frequency (rad/sample)');
ylabel('|H(e^{jω})|');
grid on;
subplot(2,1,2);
title('Phase Response');
xlabel('Frequency (rad/sample)');
ylabel('Phase (radians)');
grid on;
5. Simulating Aliasing
fs_orig = 10000; % High sampling rate for continuous signal (10 kHz)
x_recon = zeros(size(t_interp));
for i = 1:length(t_interp)
end
figure;
% Plot the original continuous signal
subplot(4,1,1);
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(4,1,2);
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(4,1,3);
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(4,1,4);
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
6. Compute and Plot DTFT of sinc(n/5)
% Define the sequence x[n] = sinc(n/5)
n = -50:50; % Discrete time indices (you can adjust the range as needed)
for k = 1:length(omega)
end
figure;
subplot(2, 1, 1);
xlabel('Frequency (\omega)');
ylabel('Magnitude');
grid on;
subplot(2, 1, 2);
xlabel('Frequency (\omega)');
ylabel('Phase (radians)');
grid on;
7. Generate a finite-duration sinusoidal signal and compute its DFS
x = sin(2 * pi * f * n / fs);
X = fft(x);
% Plot the finite-duration sinusoid and its DFS
figure;
subplot(2, 1, 1);
xlabel('n (samples)');
ylabel('x[n]');
grid on;
subplot(2, 1, 2);
f_x = abs(X);
ylabel('|X[k]|');
grid on;
X_periodic = fft(x_periodic);
figure;
subplot(2, 1, 1);
xlabel('n (samples)');
ylabel('x[n]');
grid on;
subplot(2, 1, 2);
f_x_periodic = abs(X_periodic);
ylabel('|X[k]|');
grid on;
8. DTFT of x[n] = 0.5^n for n ≥ 0
end
figure;
subplot(2,1,1);
xlabel('\omega (rad/sample)');
ylabel('|X(\omega)|');
grid on;
subplot(2,1,2);
xlabel('\omega (rad/sample)');
ylabel('Phase(X(\omega))');
grid on;
9. Signal Reconstruction using dtft and ideal interpolators
for k = 1:length(omega)
end
end
% Plot the original, undersampled, and reconstructed signals
figure;
subplot(3,1,1);
title('Original Signal');
xlabel('n (samples)');
ylabel('x[n]');
grid on;
subplot(3,1,2);
title('Undersampled Signal');
xlabel('n (samples)');
ylabel('x[n]');
grid on;
subplot(3,1,3);
xlabel('n (samples)');
ylabel('x[n]');
grid on;