From 73565ff61a23d277194ad9d2d891b4dbfe03ccc9 Mon Sep 17 00:00:00 2001 From: rainydaysavings Date: Sat, 24 Oct 2020 22:38:49 +0100 Subject: [PATCH] ex14: terminated. --- TP1b/DiogoEliseuHugo_TP2_13.m | 11 +++++++---- TP1b/DiogoEliseuHugo_TP2_14.m | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 TP1b/DiogoEliseuHugo_TP2_14.m diff --git a/TP1b/DiogoEliseuHugo_TP2_13.m b/TP1b/DiogoEliseuHugo_TP2_13.m index 52423b9..be1c270 100644 --- a/TP1b/DiogoEliseuHugo_TP2_13.m +++ b/TP1b/DiogoEliseuHugo_TP2_13.m @@ -6,15 +6,18 @@ function [Vmax, Lmax] = DiogoEliseuHugo_TP2_13(X, Y, GRAF) n4 = 1:(size(Y, 2) * 2) - 1; n5 = 1:(max(size(X, 2), size(Y, 2)) * 2) - 1; - rxx = xcorr(X, X); - ryy = xcorr(Y, Y); + rxx = xcorr(X); + ryy = xcorr(Y); X0 = max(rxx); Y0 = max(ryy); R0xx = rxx / X0; R0yy = ryy / Y0; - R0xy = xcorr(X, Y) / sqrt(X0 * Y0); - + R0xy = xcorr(X, Y, size(n5, 1)) / sqrt(X0 * Y0); + + n5 = size(R0xy, 1); + if (GRAF == 1) + figure subplot(5,1,1),plot(n1, X) xlabel('n'),title('$x[n]$', 'Interpreter', 'latex', 'FontSize', 14) subplot(5,1,2),plot(n2, Y) diff --git a/TP1b/DiogoEliseuHugo_TP2_14.m b/TP1b/DiogoEliseuHugo_TP2_14.m new file mode 100644 index 0000000..e2d3583 --- /dev/null +++ b/TP1b/DiogoEliseuHugo_TP2_14.m @@ -0,0 +1,15 @@ +%% ExercĂ­cio 14 + +function RefN = DiogoEliseuHugo_TP2_14(X) + N = 1:size(X, 2); + ref = [sin(N); exp(N); exp(-N); N; -N; N.^2]; + maxim = []; + + for s = ref' + Vmax = DiogoEliseuHugo_TP2_13(X, s', 1); + maxim = [maxim Vmax]; + end + + m = max(maxim); + RefN = find(maxim == m, 1); +end \ No newline at end of file