DSP_homework03

clear all; close all;
warning('off','MATLAB:dispatcher:InexactMatch')
% 3rd Homework 'Chebyshev & Butterworth FILTERS'
%  1. (a) Design a analog Chebyshev LPF with the following properties :
%   wc=10rad/s, Max 1dB ripple, N=4
%  (b) Verify the result you obtained by drawing |H(w)|

OmegaC = 10;
Rp = 1;
N = 4;
% ep      = sqrt(10^(Rp/10)-1);

cheby = mkfilter(OmegaC,N,'cheby',Rp);
[mag1, pha1] = bode(cheby);

figure('name', '#1 - Chebyshev Analog Filter', 'Position', [50, 350, 500, 300], 'MenuBar', 'none')
stem3 (mag1, 'DisplayName', 'mag1');
title('Magnitude Response')
xlabel('Analog frequency in pi units'); zlabel('|H|');

%  2. (a) According to the digital Butterworth LPF, draw |H(omega)| and
%  discuss whether the spectrum meets the requirements of the problem.
%  
%  (b)For input x[n]=cos(pi/6*n)+cos(pi/2*n), n=0,1,…23  plot y[n], and
%  |Y(omega)| and compare them with x[n] and |X(omega)| where y[n]=
%  x[n]*h[n]

butterw = mkfilter(OmegaC,N,'butterw',Rp);
[mag2, pha2] = bode(butterw);

figure('name', '#2 (a) - Butterworth Digital Filter', 'Position', [100, 300, 500, 300], 'MenuBar', 'none')
stem3 (mag2, 'DisplayName', 'mag2');
title('Magnitude Response')
xlabel('Analog frequency in pi units'); zlabel('|H|');

N = 0:23;
input_x =   cos(pi/6*N)+cos(pi/2*N);
[db1,mag3,pha,grd,w] = freqz_m(input_x,1);
for p= 1:52
    ma2(p) = mag2(:,:,p);
    mag4(p) = mag3(p) .* ma2(p);
end
figure('name', '#2 (b) y[n], |Y[omega]|', 'Position', [150, 150, 600, 400], 'MenuBar', 'none')
subplot(2,2,1); stem(input_x); hold all;
subplot(2,2,2); plot(ma2);
subplot(2,2,3); plot(mag3);
subplot(2,2,4); plot(mag4); hold off; figure(gcf)

'예외처리' 카테고리의 다른 글

DSP_homework04  (0) 2008.05.13
DSP_homework02  (0) 2008.05.13
DSP_homework01  (0) 2008.05.13