디지털신호처리과목 DSP필터설계
- 최초 등록일
- 2015.12.14
- 최종 저작일
- 2014.03
- 12페이지/ 한컴오피스
- 가격 3,000원
목차
없음
본문내용
1. myfir.m 과 myiir.m의 Code
< myfir.m >
Ns = 2; % [sec]
fm = 200; % frequency of message signal
fn = 1000; % frequency of noise signal
Fs = 8000; % sampling frequency
N = Fs * Ns; % number of samples
n = [0:N-1];
x1 = cos(2*pi*(fm/Fs)*n); % message signal generation
x2 = cos(2*pi*(fn/Fs)*n); % noise signal generation
x = x1 + x2;
M = 20;
fc = 600;
wc = fc/(Fs/2);
B = fir1(M,wc);
[H, w] = freqz(B,1);
mag = abs(H);
db = 20*log10((mag+eps)/max(mag));
subplot(3,1,1);
stem([0:20],abs(B)); grid;
ylim([-0.2 0.2]);
subplot(3,1,2);
plot(w/pi,mag); grid;
subplot(3,1,3);
plot(w/pi,db); grid;
y = filter(B,1,x);
L = Fs/fm*10;
Xk = fftshift(fft(x, L));
Yk = fftshift(fft(y, L));
figure
subplot(2,2,1); plot(x);
xlim([0 400]); ylim([-2 2]);
subplot(2,2,2); plot(abs(Xk));
xlim([0 400]); ylim([0 250]);
subplot(2,2,3); plot(y);
xlim([0 400]); ylim([-2 2]);
subplot(2,2,4); plot(abs(Yk));
xlim([0 400]); ylim([0 200]);
soundsc(x,Fs);
sprintf('Press Any Key!')
pause
soundsc(y,Fs);
참고 자료
없음