From 19a7ef17a02faa6c1e4460b65771380535d49bd1 Mon Sep 17 00:00:00 2001 From: rainydaysavings Date: Mon, 5 Oct 2020 21:15:29 +0100 Subject: [PATCH] ex2: terminated. --- DiogoEliseu_TP2_1.m | 2 +- DiogoEliseu_TP2_2.m | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 DiogoEliseu_TP2_2.m diff --git a/DiogoEliseu_TP2_1.m b/DiogoEliseu_TP2_1.m index 3ba8de5..812db2b 100644 --- a/DiogoEliseu_TP2_1.m +++ b/DiogoEliseu_TP2_1.m @@ -8,7 +8,7 @@ n = -20:20; % janela impulso = zeros(1,41); impulso(21) = 1; -% Degraup def +% Degrau def degrau = (n >= 0); % Figura com os resultados diff --git a/DiogoEliseu_TP2_2.m b/DiogoEliseu_TP2_2.m new file mode 100644 index 0000000..758cb16 --- /dev/null +++ b/DiogoEliseu_TP2_2.m @@ -0,0 +1,32 @@ +%% Exercício 2 +function DiogoEliseu_TP2_2(N1, N2) + n = N1:N2; + + % Impulso def + impulso = zeros(1, abs(N1) + N2 + 1); + impulso(ceil(length(n)/2)) = 1; + + % Degrau def + degrau = (n >= 0); + + % Figura com os resultados + figure + % Plot da sequência X + subplot(2,2,1:2) + x = fun_x(n); + stem(n, x) + % Plot do impulso + subplot(2,2,3) + stem(n, impulso) + % Plot do degrau + subplot(2,2,4) + stem(n, degrau) +end + +%% Definição da sequência X +function p = fun_x(N) + A=1.8; + f=0.05; + phi=0.5*pi; + p=A*cos(2*pi*f*N+phi); +end \ No newline at end of file