본문내용
y domain에서 도시하고 전달함수와 입력 신호를 Z-transform 취하여 곱한 것을 다시 inverse Z-transform취하여 출력 신호를 도시한다.
3.Source
w = 150;%cancel될 주파수
fs=1500;%sampling freq.
ts=1/fs;
t= 0 : ts : 1-ts;
fn = -fs/2 : fs/2-1;
f1 =60;
f2= 150;
a1=2;
a2=5;
s1=a1*sin(2*pi*f1*t);
s2=a2*sin(2*pi*f2*t);
s3 = s1+s2;%합성한 신호
figure(1);
subplot(211);%첫번째 창에는 time domain에서 생성한 신호를 plotting
plot(t,s1,t,s2);%각각의 sine wave를 plotting
axis([0 0.1 -10 10]);
title('s1 and s2 in time domain');
xlabel('Time(s)'); ylabel('Amplitude')
legend('s1(t)', 's2(t)'); grid
subplot(212);
plot(t,s3);%2개의 sine wave를 합성한 신호를 plotting
axis([0 0.1 -10 10]);
title('s3 = s1 + s2');
xlabel('Time(s)'); ylabel('Amplitude');
legend('s3(t)'); grid
% {sin(2πf1t)+sin(2πf2t)}의 Fast Foureir Transform
fft_s1 = fft(s1);%신호에 대해 fft를 취함
fft_s2 = fft(s2);
fft_s3 = fft(s3);
abs_s1 = (1/fs)*abs(fftshift(fft_s1)); %fft한 값에 대해 절대 값을 취함
abs_s2 = (1/fs)*abs(fftshift(fft_s2));
abs_s3 = (1/fs)*abs(fftshift(fft_s3));
for i = 1 : length(fn);
z = exp(j*fn(i)*ts); %z parameter
H(i) =% 주파수 응답 함수
((z-exp(j*w*ts))*(z-exp(-j*w*ts)))/((z-0.999*exp(j*w*ts))*(z-0.99*exp(-j*w*ts)));
end;
H_abs = abs(H); % Magnitude
H_phase = angle(H); % Phase
Y = H_abs.*abs_s3; % filtered signal spectrum
y = ifft(Y)*fs;
figure(2) %notch filter 's impusl response (magnitude & phase)
subplot(2,1,1)
plot(fn,H_abs);
axis([0 250 -0.5 1.5])
title('Digital Notch Filter(Magnitude)');
ylabel('|H(z)|'); xlabel('Frequency'); grid;
subplot(2,1,2)
plot(fn,H_phase);
axis([0 250 -1 1.5])
title('Digital Notch Filter(phase)'); grid;
ylabel('∠H(z)'); xlabel('Frequency');
figure(3) % sinusoidal signals' spectrum
subplot(311);
stem(fn, abs_s1);
axis([-230 230 0 4])
xlabel('Frequency(Hz)'); ylabel('magnitude')
legend('S1(f)'); grid
subplot(312);
stem(fn, abs_s2);
axis([-230 230 0 4])
xlabel('Frequency(Hz)'); ylabel('magnitude')
legend('S2(f)'); grid
subplot(313);
stem(fn, abs_s3);
axis([-230 230 0 4])
xlabel('Frequency(Hz)'); ylabel('magnitude')
legend('S3(f)'); grid
figure(4) % filtered signal spectrum
subplot(2,1,1);
stem(fn, Y);
axis([ -230 230 0 2]);
title (' filtered signal spectrum (f=150 Hz removed)');
xlabel('Freqency(Hz)');
ylabel('magnitude'); grid;
subplot(2,1,2);
stem(t,y);
axis([0 0.1 -5 5]);
xlabel('Time(s)');
ylabel('Amplitude')
legend('y(n)'); grid
4.Plotting & Anaysis
Figure (1)
주파수가 60Hz과 150Hz인 두 sinusoidal signal을 generate하여 도시 하였다.
두 번째 그래프는 이 두 signal을 합성한 signal을 나타낸다.
Figure(2)
Notch filter의 전달함수 특성을 도시하였다. 위쪽의 그래프가 |H(z)|을 나타내고, 아래쪽 그래프가 ∠H(z)를 나타낸다. 주파수가 150일 때 급격히 |H(z)|값이 감소하는 것을 볼 수 있다.
Figure (3)
처음 생성한 3개의 signal을 fft 취한 것을 도시하였다. 첫 번째 그래프가 sin(2π*60*t)를 fft취한 것이고 두 번째가 sin(2π*150*t)를 fft취한 것,
세 번째가 sin(2π*60*t)+sin(2π*150*t)를 fft취한 것이다.
즉, S3={sin(2π*60*t)+ sin(2π*150*t)}
이다.
Figure(4)
Notch filter를 통과한 S3를 도시한 것이 첫 번째 그래프이고
이것을 다시 inverse transform 취한 것이 두 번째 그래프이다.
6oHz 성분 밖에 나타나지 않는 것으로 보아 filter에 의해 150Hz 성분이 cancel되었음을 알 수 있다.
그러나 이것을 inverse 취한 그래프에서는 150Hz 성분이 영향을 끼치는 것을 알 수 있는데 이것은 filter가 완벽히 150Hz 성분을 제거하지 못했기 때문인 것 같다.
3.Source
w = 150;%cancel될 주파수
fs=1500;%sampling freq.
ts=1/fs;
t= 0 : ts : 1-ts;
fn = -fs/2 : fs/2-1;
f1 =60;
f2= 150;
a1=2;
a2=5;
s1=a1*sin(2*pi*f1*t);
s2=a2*sin(2*pi*f2*t);
s3 = s1+s2;%합성한 신호
figure(1);
subplot(211);%첫번째 창에는 time domain에서 생성한 신호를 plotting
plot(t,s1,t,s2);%각각의 sine wave를 plotting
axis([0 0.1 -10 10]);
title('s1 and s2 in time domain');
xlabel('Time(s)'); ylabel('Amplitude')
legend('s1(t)', 's2(t)'); grid
subplot(212);
plot(t,s3);%2개의 sine wave를 합성한 신호를 plotting
axis([0 0.1 -10 10]);
title('s3 = s1 + s2');
xlabel('Time(s)'); ylabel('Amplitude');
legend('s3(t)'); grid
% {sin(2πf1t)+sin(2πf2t)}의 Fast Foureir Transform
fft_s1 = fft(s1);%신호에 대해 fft를 취함
fft_s2 = fft(s2);
fft_s3 = fft(s3);
abs_s1 = (1/fs)*abs(fftshift(fft_s1)); %fft한 값에 대해 절대 값을 취함
abs_s2 = (1/fs)*abs(fftshift(fft_s2));
abs_s3 = (1/fs)*abs(fftshift(fft_s3));
for i = 1 : length(fn);
z = exp(j*fn(i)*ts); %z parameter
H(i) =% 주파수 응답 함수
((z-exp(j*w*ts))*(z-exp(-j*w*ts)))/((z-0.999*exp(j*w*ts))*(z-0.99*exp(-j*w*ts)));
end;
H_abs = abs(H); % Magnitude
H_phase = angle(H); % Phase
Y = H_abs.*abs_s3; % filtered signal spectrum
y = ifft(Y)*fs;
figure(2) %notch filter 's impusl response (magnitude & phase)
subplot(2,1,1)
plot(fn,H_abs);
axis([0 250 -0.5 1.5])
title('Digital Notch Filter(Magnitude)');
ylabel('|H(z)|'); xlabel('Frequency'); grid;
subplot(2,1,2)
plot(fn,H_phase);
axis([0 250 -1 1.5])
title('Digital Notch Filter(phase)'); grid;
ylabel('∠H(z)'); xlabel('Frequency');
figure(3) % sinusoidal signals' spectrum
subplot(311);
stem(fn, abs_s1);
axis([-230 230 0 4])
xlabel('Frequency(Hz)'); ylabel('magnitude')
legend('S1(f)'); grid
subplot(312);
stem(fn, abs_s2);
axis([-230 230 0 4])
xlabel('Frequency(Hz)'); ylabel('magnitude')
legend('S2(f)'); grid
subplot(313);
stem(fn, abs_s3);
axis([-230 230 0 4])
xlabel('Frequency(Hz)'); ylabel('magnitude')
legend('S3(f)'); grid
figure(4) % filtered signal spectrum
subplot(2,1,1);
stem(fn, Y);
axis([ -230 230 0 2]);
title (' filtered signal spectrum (f=150 Hz removed)');
xlabel('Freqency(Hz)');
ylabel('magnitude'); grid;
subplot(2,1,2);
stem(t,y);
axis([0 0.1 -5 5]);
xlabel('Time(s)');
ylabel('Amplitude')
legend('y(n)'); grid
4.Plotting & Anaysis
Figure (1)
주파수가 60Hz과 150Hz인 두 sinusoidal signal을 generate하여 도시 하였다.
두 번째 그래프는 이 두 signal을 합성한 signal을 나타낸다.
Figure(2)
Notch filter의 전달함수 특성을 도시하였다. 위쪽의 그래프가 |H(z)|을 나타내고, 아래쪽 그래프가 ∠H(z)를 나타낸다. 주파수가 150일 때 급격히 |H(z)|값이 감소하는 것을 볼 수 있다.
Figure (3)
처음 생성한 3개의 signal을 fft 취한 것을 도시하였다. 첫 번째 그래프가 sin(2π*60*t)를 fft취한 것이고 두 번째가 sin(2π*150*t)를 fft취한 것,
세 번째가 sin(2π*60*t)+sin(2π*150*t)를 fft취한 것이다.
즉, S3={sin(2π*60*t)+ sin(2π*150*t)}
이다.
Figure(4)
Notch filter를 통과한 S3를 도시한 것이 첫 번째 그래프이고
이것을 다시 inverse transform 취한 것이 두 번째 그래프이다.
6oHz 성분 밖에 나타나지 않는 것으로 보아 filter에 의해 150Hz 성분이 cancel되었음을 알 수 있다.
그러나 이것을 inverse 취한 그래프에서는 150Hz 성분이 영향을 끼치는 것을 알 수 있는데 이것은 filter가 완벽히 150Hz 성분을 제거하지 못했기 때문인 것 같다.
소개글