cleanup.
This commit is contained in:
parent
16a3407843
commit
97c9ede3b5
|
@ -1,7 +1,7 @@
|
||||||
%% Exercício 2
|
%% Exercício 2
|
||||||
function DiogoEliseuHugo_TP2_2(N1, N2)
|
function DiogoEliseuHugo_TP2_2(N1, N2)
|
||||||
n = N1:N2;
|
n = N1:N2;
|
||||||
|
|
||||||
% Impulso def
|
% Impulso def
|
||||||
impulso = zeros(1, abs(N1) + N2 + 1);
|
impulso = zeros(1, abs(N1) + N2 + 1);
|
||||||
impulso(ceil(length(n)/2)) = 1;
|
impulso(ceil(length(n)/2)) = 1;
|
||||||
|
@ -29,4 +29,4 @@ function p = fun_x(N)
|
||||||
f=0.05;
|
f=0.05;
|
||||||
phi=0.5*pi;
|
phi=0.5*pi;
|
||||||
p=A*cos(2*pi*f*N+phi);
|
p=A*cos(2*pi*f*N+phi);
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
%% Exercício 5
|
%% Exercício 5
|
||||||
function DiogoEliseuHugo_TP2_5(X)
|
function DiogoEliseuHugo_TP2_5(X)
|
||||||
plot(X);
|
plot(X);
|
||||||
fprintf("L_1: %d\n", norma(X,1));
|
fprintf('L_1: %d\n', norma(X,1));
|
||||||
fprintf("L_2: %f\n", norma(X,2));
|
fprintf('L_2: %f\n', norma(X,2));
|
||||||
fprintf("L_3: %f\n", norma(X,3));
|
fprintf('L_3: %f\n', norma(X,3));
|
||||||
fprintf("L_{infinity}: %d\n", max(abs(X)));
|
fprintf('L_{infinity}: %d\n', max(abs(X)));
|
||||||
fprintf("Energia: %f\n", sum(abs(X).^2));
|
fprintf('Energia: %f\n', sum(abs(X).^2));
|
||||||
fprintf("Potência média: %f\n", sum(X.^2) / length(X));
|
fprintf('Potência média: %f\n', sum(X.^2) / length(X));
|
||||||
end
|
end
|
||||||
|
|
||||||
function s = norma(X, P)
|
function s = norma(X, P)
|
||||||
s = sum(abs(X).^P).^(1/P);
|
s = sum(abs(X).^P).^(1/P);
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,6 @@ plot(y5)
|
||||||
|
|
||||||
hold off
|
hold off
|
||||||
|
|
||||||
legend("s","x","y3","y5");
|
legend('s','x','y3','y5');
|
||||||
errors = ['Ex: ' num2str(DiogoEliseuHugo_TP2_6(x, s)) ' Ey3: ' num2str(DiogoEliseuHugo_TP2_6(y3, s)) ' Ey5: ' num2str(DiogoEliseuHugo_TP2_6(y5, s))];
|
errors = ['Ex: ' num2str(DiogoEliseuHugo_TP2_6(x, s)) ' Ey3: ' num2str(DiogoEliseuHugo_TP2_6(y3, s)) ' Ey5: ' num2str(DiogoEliseuHugo_TP2_6(y5, s))];
|
||||||
title(errors)
|
title(errors)
|
||||||
|
|
Reference in New Issue