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/DiogoEliseuHugo_TP2_8.m

43 lines
823 B
Mathematica
Raw Normal View History

2020-10-06 00:44:22 +01:00
%% Inicialização do ambiente
clear ; close all; clc
% Definimos uma seed estatica para o gerador de números aleatórios de forma
% a podermos repetir os experimentos com resultados determinísticos
rng(42);
%% Exercício 8
2020-10-08 15:06:17 +01:00
N_len = 81;
N = 0:(N_len-1);
2020-10-06 00:44:22 +01:00
s = 2 * N .* (0.9.^N);
2020-10-08 15:06:17 +01:00
r = rand(1,N_len) - 0.5;
2020-10-06 00:44:22 +01:00
x = s + r;
2020-10-08 15:06:17 +01:00
xc = [0 x 0];
xe = [x 0 0];
xd = [0 0 x];
2020-10-06 00:44:22 +01:00
figure
hold on
plot(s)
plot(x)
2020-10-08 15:06:17 +01:00
xnovo = (xc + xe + xd) / 3;
y3 = xnovo(2:N_len+1);
plot(y3)
2020-10-06 00:44:22 +01:00
2020-10-08 15:06:17 +01:00
xc = [0 0 x 0 0];
xe = [x 0 0 0 0];
xd = [0 0 0 0 x];
xee = [0 x 0 0 0];
xdd = [0 0 0 x 0];
xnovo = (xc + xe + xd + xee + xdd) / 5;
y5 = xnovo(4:N_len+3);
plot(y5)
2020-10-06 00:44:22 +01:00
2020-10-08 15:06:17 +01:00
hold off
2020-10-06 00:44:22 +01:00
2020-10-08 15:28:47 +01:00
legend('s','x','y3','y5');
2020-10-08 15:26:33 +01:00
errors = ['Ex: ' num2str(DiogoEliseuHugo_TP2_6(x, s)) ' Ey3: ' num2str(DiogoEliseuHugo_TP2_6(y3, s)) ' Ey5: ' num2str(DiogoEliseuHugo_TP2_6(y5, s))];
2020-10-08 15:28:47 +01:00
title(errors)