Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

필터 설계 갤러리

이 예제에서는 Signal Processing Toolbox® 제품에서 designfilt 함수를 사용하여 다양한 FIR 및 IIR 디지털 필터를 설계하는 방법을 보여줍니다.

이 갤러리는 관심 있는 필터 응답을 식별하고, 코드를 확인하고, 이를 자신의 프로젝트에 사용할 수 있도록 설계되었습니다. 이 갤러리에는 designfilt가 제공하는 필터 응답 각각에 대한 예제가 포함되어 있습니다. 그러나, 여기 예제는 각 응답 유형별로 필터를 설계할 수 있는 방법 중 일부에 불과합니다. 필터 사양 세트에 관한 전체 목록은 Signal Processing Toolbox 문서를 참조하십시오.

별도로 명시한 경우를 제외하고, 이 예제에서 모든 주파수는 헤르츠 단위이고, 모든 리플 값과 감쇠량 값은 데시벨 단위입니다.

저역통과 FIR 필터

등리플 설계

Fpass = 100;
Fstop = 150;
Apass = 1;
Astop = 65;
Fs = 1e3;

d = designfilt('lowpassfir', ...
  'PassbandFrequency',Fpass,'StopbandFrequency',Fstop, ...
  'PassbandRipple',Apass,'StopbandAttenuation',Astop, ...
  'DesignMethod','equiripple','SampleRate',Fs);

fvtool(d)

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

저역통과 IIR 필터

최대 평탄(Maximally flat) 설계

Fpass = 100;
Fstop = 150;
Apass = 0.5;
Astop = 65;
Fs = 1e3;

d = designfilt('lowpassiir', ...
  'PassbandFrequency',Fpass,'StopbandFrequency',Fstop, ...
  'PassbandRipple',Apass,'StopbandAttenuation',Astop, ...
  'DesignMethod','butter','SampleRate',Fs);

fvtool(d)

Figure Figure 2: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

통과대역 및 저지대역 리플

N = 8;
Fpass = 100;
Apass = 0.5;
Astop = 65;
Fs = 1e3;

d = designfilt('lowpassiir', ...
  'FilterOrder',N, ...  
  'PassbandFrequency',Fpass, ...
  'PassbandRipple',Apass,'StopbandAttenuation',Astop, ...
  'SampleRate',Fs);

fvtool(d)

Figure Figure 3: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

고역통과 FIR 필터

등리플 설계

Fstop = 350;
Fpass = 400;
Astop = 65;
Apass = 0.5;
Fs = 1e3;

d = designfilt('highpassfir','StopbandFrequency',Fstop, ...
  'PassbandFrequency',Fpass,'StopbandAttenuation',Astop, ...
  'PassbandRipple',Apass,'SampleRate',Fs,'DesignMethod','equiripple');

fvtool(d)

Figure Figure 4: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

고역통과 IIR 필터

최대 평탄(Maximally flat) 설계

Fstop = 350;
Fpass = 400;
Astop = 65;
Apass = 0.5;
Fs = 1e3;

d = designfilt('highpassiir','StopbandFrequency',Fstop ,...
  'PassbandFrequency',Fpass,'StopbandAttenuation',Astop, ...
  'PassbandRipple',Apass,'SampleRate',Fs,'DesignMethod','butter');

fvtool(d)

Figure Figure 5: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

통과대역 및 저지대역 리플

N = 8;
Fpass = 400;
Astop = 65;
Apass = 0.5;
Fs = 1e3;

d = designfilt('highpassiir', ...
  'FilterOrder',N, ...  
  'PassbandFrequency',Fpass, ...
  'StopbandAttenuation',Astop,'PassbandRipple',Apass, ...
  'SampleRate',Fs);

fvtool(d)

Figure Figure 6: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

대역통과 FIR 필터

등리플 설계

Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Astop1 = 65;
Apass  = 0.5;
Astop2 = 65;
Fs = 1e3;

d = designfilt('bandpassfir', ...
  'StopbandFrequency1',Fstop1,'PassbandFrequency1', Fpass1, ...
  'PassbandFrequency2',Fpass2,'StopbandFrequency2', Fstop2, ...
  'StopbandAttenuation1',Astop1,'PassbandRipple', Apass, ...
  'StopbandAttenuation2',Astop2, ...
  'DesignMethod','equiripple','SampleRate',Fs);

fvtool(d)

Figure Figure 7: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

비대칭 대역 감쇠

N = 50;
Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Wstop1 = 3;
Wstop2 = 100;
Fs = 1e3;

d = designfilt('bandpassfir', ...
  'FilterOrder',N, ...
  'StopbandFrequency1',Fstop1,'PassbandFrequency1', Fpass1, ...
  'PassbandFrequency2',Fpass2,'StopbandFrequency2', Fstop2, ...
  'StopbandWeight1',Wstop1,'StopbandWeight2',Wstop2, ...
   'DesignMethod','equiripple','SampleRate',Fs);
  
fvtool(d)

Figure Figure 8: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

대역통과 IIR 필터

최대 평탄(Maximally flat) 설계

Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Astop1 = 65;
Apass  = 0.5;
Astop2 = 65;
Fs = 1e3;

d = designfilt('bandpassiir', ...
  'StopbandFrequency1',Fstop1,'PassbandFrequency1', Fpass1, ...
  'PassbandFrequency2',Fpass2,'StopbandFrequency2', Fstop2, ...
  'StopbandAttenuation1',Astop1,'PassbandRipple', Apass, ...
  'StopbandAttenuation2',Astop2, ...
  'DesignMethod','butter','SampleRate', Fs);

fvtool(d)

Figure Figure 9: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

통과대역 및 저지대역 리플

N = 8;
Fpass1 = 200;
Fpass2 = 300;
Astop1 = 65;
Apass  = 0.5;
Astop2 = 65;
Fs = 1e3;

d = designfilt('bandpassiir', ...
  'FilterOrder',N, ...
  'PassbandFrequency1', Fpass1,'PassbandFrequency2', Fpass2, ...
  'StopbandAttenuation1', Astop1, 'PassbandRipple', Apass, ...
  'StopbandAttenuation2', Astop2, ...
  'SampleRate', Fs);

fvtool(d)

Figure Figure 10: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

대역저지 FIR 필터

등리플 설계

Fpass1 = 100;
Fstop1 = 150;
Fstop2 = 350;
Fpass2 = 400;
Apass1 = 0.5;
Astop  = 65;
Apass2 = 0.5;
Fs = 1e3;

d = designfilt('bandstopfir', ...
  'PassbandFrequency1',Fpass1,'StopbandFrequency1',Fstop1, ...
  'StopbandFrequency2',Fstop2,'PassbandFrequency2',Fpass2, ...
  'PassbandRipple1',Apass1,'StopbandAttenuation',Astop, ...
  'PassbandRipple2', Apass2, ...
  'DesignMethod','equiripple','SampleRate', Fs);

fvtool(d)

Figure Figure 11: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

비대칭 통과대역 리플

N = 30;
Fpass1 = 100;
Fstop1 = 150;
Fstop2 = 350;
Fpass2 = 400;
Wpass1 = 1;
Wpass2  = 10;
Fs = 1e3;

d = designfilt('bandstopfir', ...
  'FilterOrder',N, ...
  'PassbandFrequency1',Fpass1,'StopbandFrequency1',Fstop1, ...
  'StopbandFrequency2',Fstop2,'PassbandFrequency2',Fpass2, ...
  'PassbandWeight1',Wpass1,'PassbandWeight2',Wpass2, ...
  'DesignMethod','equiripple','SampleRate', Fs);

fvtool(d)

Figure Figure 12: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

대역저지 IIR 필터

최대 평탄(Maximally flat) 설계

Fpass1 = 100;
Fstop1 = 150;
Fstop2 = 350;
Fpass2 = 400;
Apass1 = 0.5;
Astop  = 65;
Apass2 = 0.5;
Fs = 1e3;

d = designfilt('bandstopiir', ...
  'PassbandFrequency1',Fpass1,'StopbandFrequency1',Fstop1, ...
  'StopbandFrequency2',Fstop2,'PassbandFrequency2',Fpass2, ...
  'PassbandRipple1',Apass1,'StopbandAttenuation',Astop, ...
  'PassbandRipple2', Apass2, ...
  'DesignMethod','butter','SampleRate', Fs);

fvtool(d)

Figure Figure 13: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

통과대역 및 저지대역 리플

N = 8;
Fpass1 = 125;
Fpass2 = 375;
Apass = 0.5;
Astop  = 65;
Fs = 1e3;

d = designfilt('bandstopiir', ...
  'FilterOrder',N, ...
  'PassbandFrequency1',Fpass1,'PassbandFrequency2',Fpass2, ...
  'PassbandRipple',Apass,'StopbandAttenuation', Astop, ...
  'SampleRate',Fs);

fvtool(d)

Figure Figure 14: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Frequency (Hz), ylabel Magnitude (dB) contains 2 objects of type line.

임의 크기 FIR 필터

단일대역 임의 크기 설계

N = 300;

% Frequencies are in normalized units
F1 = 0:0.01:0.18;
F2 = [.2 .38 .4 .55 .562 .585 .6 .78];
F3 = 0.79:0.01:1;
FreqVect = [F1 F2 F3]; % vector of frequencies

% Define desired response using linear units
A1 = .5+sin(2*pi*7.5*F1)/4;    % Sinusoidal section
A2 = [.5 2.3 1 1 -.2 -.2 1 1]; % Piecewise linear section
A3 = .2+18*(1-F3).^2;          % Quadratic section

AmpVect = [A1 A2 A3];

d = designfilt('arbmagfir',...
  'FilterOrder',N,'Amplitudes',AmpVect,'Frequencies',FreqVect,...
  'DesignMethod','freqsamp');

fvtool(d,'MagnitudeDisplay','Zero-phase')

Figure Figure 15: Zero-phase Response contains an axes object. The axes object with title Zero-phase Response, xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Amplitude contains 2 objects of type line.

저지대역에서 계단 모양으로 감쇠하는 다중대역 저역통과 설계

N = 150;
B = 2; % Number of bands
% Frequencies are in normalized units
F1 = [0 .25]; % Passband
F2 = [.3 .4 .401 .5 .501 .6 .601 .7 .701 .8 .801 .9 .901 1]; % Stopband
A1 = ones(size(F1));  % Desired amplitudes for band 1 in linear units
A2 = zeros(size(F2)); % Desired amplitudes for band 2 in linear units
% Vector of weights
W = 10.^([0 0 5 5 10 10 15 15 20 20 25 25 30 30 35 35]/20);
W1 = W(1:2);   % Weights for band 1
W2 = W(3:end); % Weights for band 2

d = designfilt('arbmagfir', ...
  'FilterOrder',N,'NumBands',B, ...
  'BandFrequencies1',F1,'BandAmplitudes1',A1, ...
  'BandFrequencies2',F2,'BandAmplitudes2',A2, ...
  'BandWeights1',W1,'BandWeights2', W2);

fvtool(d)

Figure Figure 16: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains 2 objects of type line.

미분기 FIR 필터

전대역 설계

N = 41;
Fs = 1e3;

d = designfilt('differentiatorfir', ...
'FilterOrder',N, 'DesignMethod','equiripple','SampleRate',Fs);

fvtool(d,'MagnitudeDisplay','zero-phase','OverlayedAnalysis','phase')

Figure Figure 17: Zero-phase Response and Phase Response contains an axes object. The axes object with title Zero-phase Response and Phase Response, xlabel Frequency (Hz), ylabel Amplitude contains an object of type line.

부분대역 설계

N = 40;
Fpass = 100;
Fstop = 150;
Fs = 1e3;

d = designfilt('differentiatorfir', ...
'FilterOrder',N, ...
'PassbandFrequency',Fpass,'StopbandFrequency',Fstop, ...
'DesignMethod','equiripple','SampleRate',Fs);

fvtool(d,'MagnitudeDisplay','zero-phase','OverlayedAnalysis','phase')

Figure Figure 18: Zero-phase Response and Phase Response contains an axes object. The axes object with title Zero-phase Response and Phase Response, xlabel Frequency (Hz), ylabel Amplitude contains an object of type line.

힐베르트 FIR 필터

등리플 설계

N = 40;
Tw = 50;
Fs = 1e3;

d = designfilt('hilbertfir', ...
'FilterOrder',N,'TransitionWidth',Tw, ...
'DesignMethod','equiripple','SampleRate',Fs);

fvtool(d,'MagnitudeDisplay','Zero-phase','OverlayedAnalysis','phase')

Figure Figure 19: Zero-phase Response and Phase Response contains an axes object. The axes object with title Zero-phase Response and Phase Response, xlabel Frequency (Hz), ylabel Amplitude contains an object of type line.

참고 항목

|