From d92f141b723b85f2f7aa91d0c005b620d78547a3 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Sun, 15 Nov 2020 21:51:27 +0000 Subject: [PATCH] Insane Progress --- TP2/DiogoEliseu_TP2_1.m | 3 +- TP2/DiogoEliseu_TP2_2.m | 26 +++++++++------ TP2/DiogoEliseu_TP2_3.m | 73 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 TP2/DiogoEliseu_TP2_3.m diff --git a/TP2/DiogoEliseu_TP2_1.m b/TP2/DiogoEliseu_TP2_1.m index 22bdeb5..81bbb1a 100644 --- a/TP2/DiogoEliseu_TP2_1.m +++ b/TP2/DiogoEliseu_TP2_1.m @@ -2,8 +2,7 @@ p = [1.8, 0.5, -0.3]; d = [1, 0.5]; -w = 0:(4*pi/1023):2*pi; -y2a = freqz(p, d, w); +w = -4*pi:(8*pi/999):4*pi; X = freqz(p, d, w); subplot(2,1,1),plot(w, abs(X)) diff --git a/TP2/DiogoEliseu_TP2_2.m b/TP2/DiogoEliseu_TP2_2.m index 352a413..a677930 100644 --- a/TP2/DiogoEliseu_TP2_2.m +++ b/TP2/DiogoEliseu_TP2_2.m @@ -1,19 +1,25 @@ %% Exercício 2 -w1 = (0:15) * 2 * pi / 16; -w2 = (0:1023) * 2 * pi / 1024; -x1 = ones(1,16); -x2 = cos(3 * pi * (0:15) / 8); +N = (0:15); -DFT1 = fft(x1); +x1 = ones(1,16); +x2 = cos(3*pi.*N./8); + +DFT1 = fft(x1, 16); DTFT1 = fft(x1, 1024); -DFT2 = fft(x2); +DFT2 = fft(x2, 16); DTFT2 = fft(x2, 1024); subplot(2,1,1) -plot(w1, abs(DFT1), w2, abs(DTFT1)) -xlabel('cenas'), ylabel('Modulo'), title('DFT / DTFT de x1') +stem(x2) subplot(2,1,2) -plot(w1, abs(DFT2), w2, abs(DTFT2)) -xlabel('cenas'), ylabel('Modulo'), title('DFT / DTFT de x2') \ No newline at end of file +hold on +stem(X(16),abs(DFT2)) +plot(X(1024), abs(DTFT2)) +hold off +xlabel('cenas'), ylabel('Modulo'), title('DFT / DTFT de x2') + +function f = X(N) +f = 0:(1/N):(1 - 1/N); +end \ No newline at end of file diff --git a/TP2/DiogoEliseu_TP2_3.m b/TP2/DiogoEliseu_TP2_3.m new file mode 100644 index 0000000..03b24d5 --- /dev/null +++ b/TP2/DiogoEliseu_TP2_3.m @@ -0,0 +1,73 @@ +% Exercício 3 +% signals +N = 256; +n = (0:N-1); +X1 = 2*N*0.97.^n; +X2 = cos(6*pi*n/N); +X3 = sin(12*pi*n/N); + +% freq conv +X1_fft = fft(X1); +X2_fft = fft(X2); +X3_fft = fft(X3); +X1_X2_f = ifft(X1_fft.*X2_fft); +X1_X3_f = ifft(X1_fft.*X3_fft); +X2_X3_f = ifft(X2_fft.*X3_fft); + +% time conv +X1_X2_t = conv(X1, X2); +X1_X3_t = conv(X1, X3); +X2_X3_t = conv(X2, X3); + +%--- plots + +% signals +subplot(3,3,1) +plot(X1); +%title("Sinal X1") +xlabel("n") +ylabel("X1") +subplot(3,3,2) +plot(X2); +title("Sinais") +xlabel("n") +ylabel("X2") +subplot(3,3,3) +plot(X3); +%title("Sinal X3") +xlabel("n") +ylabel("X3") + +% time +subplot(3,3,4) +plot(X1_X2_t); +%title("X1 * X2 no domínio do tempo") +xlabel("n") +ylabel("X1(t) * X2(t)") +subplot(3,3,5) +plot(X1_X3_t); +title("*(t)") +xlabel("n") +ylabel("X1(t) * X3(t)") +subplot(3,3,6) +plot(X2_X3_t); +%title("X2 * X3 no domínio do tempo") +xlabel("n") +ylabel("X2(t) * X3(t)") + +% freq +subplot(3,3,7) +plot(X1_X2_f); +%title("X1 * X2 no domínio da freq") +xlabel("n") +ylabel("X1(\omega) * X2(\omega)") +subplot(3,3,8) +plot(X1_X3_f); +title("*(\omega)") +xlabel("n") +ylabel("X1(\omega) * X3(\omega)") +subplot(3,3,9) +plot(X2_X3_f); +%title("X2 * X3 no domínio da freq") +xlabel("n") +ylabel("X2(\omega) * X3(\omega)")