finished exercise except for some parts of number 1

This commit is contained in:
2026-05-09 17:16:35 +02:00
parent a4f2001671
commit 99b68b10eb
14 changed files with 301 additions and 217 deletions

View File

@@ -0,0 +1,29 @@
function X = dtft ( x , n , w )
% DTFT Computes Discrete-time Fourier transform
% @param x : finite duration sequence (vector) over n
% @param n : sample indices vector
% @param w : frequency vector
% @return X : DTFT of x[n] at frequencies w
% this function does not use for loops
X = sum(x(:) .* exp(-1j * n(:) * w), 1);
end
n = -10:10;
x = (0.8) .^ abs(n) .* ((n >= -10) & (n < 11));
w = linspace(-pi, pi, 1000);
X = dtft(x, n, w);
magnitude = abs(X);
phase = angle(X);
figure;
subplot(2, 1, 1);
plot(w, magnitude);
title('Magnitude Response');
xlabel('Frequency (rad/sample)');
ylabel('|X(w)|');
subplot(2, 1, 2);
plot(w, phase);
title('Phase Response');
xlabel('Frequency (rad/sample)');
ylabel('Phase(rad)');