This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
DSP/TP2/DiogoEliseu_TP2_2.m

27 lines
449 B
Mathematica
Raw Permalink Normal View History

2020-11-12 14:46:51 +00:00
%% Exercício 2
2020-11-15 21:51:27 +00:00
N = (0:15);
2020-11-12 14:46:51 +00:00
x1 = ones(1,16);
2020-11-15 21:51:27 +00:00
x2 = cos(3*pi.*N./8);
2020-11-12 14:46:51 +00:00
2020-11-15 21:51:27 +00:00
DFT1 = fft(x1, 16);
2020-11-12 14:46:51 +00:00
DTFT1 = fft(x1, 1024);
2020-11-15 21:51:27 +00:00
DFT2 = fft(x2, 16);
2020-11-12 14:46:51 +00:00
DTFT2 = fft(x2, 1024);
subplot(2,1,1)
2020-11-15 21:51:27 +00:00
stem(x2)
2020-11-17 23:57:44 +00:00
xlabel('n'), ylabel('Amplitude'), title('Sinal x2')
2020-11-12 14:46:51 +00:00
subplot(2,1,2)
2020-11-15 21:51:27 +00:00
hold on
2020-11-17 23:57:44 +00:00
stem(X(16), abs(DFT2), "LineStyle", "none")
2020-11-15 21:51:27 +00:00
plot(X(1024), abs(DTFT2))
2020-11-17 23:57:44 +00:00
xlabel('\omega/2\pi'), ylabel('Modulo'), title('DFT / DTFT de x2')
2020-11-15 21:51:27 +00:00
hold off
function f = X(N)
f = 0:(1/N):(1 - 1/N);
end