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/TP3/DiogoEliseu_TP3_4.m
Diogo Cordeiro 459ba23074 terminated
2020-12-14 03:11:13 +00:00

41 lines
1.2 KiB
Matlab

%% Inicialização do ambiente
clear; close all; clc
%% Exercício 4
fc = 0.3;
w = linspace(0, pi, 500); %0:pi/500:pi;
f = w/pi;
order = [ 4, 6, 8, 10];
for i=1:4
% Butterworth
subplot(3,4,i)
[num, den] = butter(order(i), fc, 'low'); %order, cutoff frequency, type
h = freqz(num, den, w);
gain = 20.*log10(abs(h));
plot(f, gain);
axis([0 1 -60 2]);
title(['Butterworth - ' num2str(order(i)) '.ª Ordem']);
ylabel("Ganho (dB)"); xlabel("\omega/\pi");
% Chebyshev
subplot(3,4,i+4)
[num, den] = cheby1(order(i), 0.5, fc, 'low'); %0.5 is tollerance in dB
h = freqz(num, den, w);
gain = 20.*log10(abs(h));
plot(f, gain);
axis([0 1 -60 2]);
title(['Chebyshev - ' num2str(order(i)) '.ª Ordem']);
ylabel("Ganho (dB)"); xlabel("\omega/\pi");
% Eliptico
subplot(3,4,i+4+4)
[num, den] = ellip(order(i), 0.5, 40, fc, 'low'); %0.5 is the tollerance in the top, -40 is the tollerance in the bottom
h = freqz(num, den, w);
gain = 20.*log10(abs(h));
plot(f, gain);
axis([0 1 -60 2]);
title(['Eliptico - ' num2str(order(i)) '.ª Ordem']);
ylabel("Ganho (dB)"); xlabel("\omega/\pi");
end