fdesign을 사용하여 필터 설계하기
다음 두 단계를 사용하여 단순 필터를 설계합니다.
필터 사양 객체를 생성합니다.
필터를 설계합니다.
대역통과 필터를 설계한다고 가정하겠습니다. 일반적으로 대역통과 필터는 다음 그림에 표시된 것처럼 정의됩니다.

이 예제에서는 샘플링 주파수 Fs = 48kHz가 사용되었습니다. 이 대역통과 필터는 다음과 같은 사양을 가집니다. 여기에서는 MATLAB® 코드를 사용하여 사양이 지정되었습니다.
A_stop1 = 60; % Attenuation in the first stopband = 60 dB F_stop1 = 8400; % Edge of the stopband = 8400 Hz F_pass1 = 10800; % Edge of the passband = 10800 Hz F_pass2 = 15600; % Closing edge of the passband = 15600 Hz F_stop2 = 18000; % Edge of the second stopband = 18000 Hz A_stop2 = 60; % Attenuation in the second stopband = 60 dB A_pass = 1; % Amount of ripple allowed in the passband = 1 dB
다음 두 단계에서, 이러한 사양은 파라미터로 fdesign.bandpass 메서드에 전달됩니다.
- 1단계
필터 사양 객체를 생성하기 위해 MATLAB 프롬프트에서 다음 코드를 실행합니다.
d = fdesign.bandpass
이제, 디폴트
Specification에 해당하는 필터 사양, 즉fst1,fp1,fp2,fst2,ast1,ap,ast2를 전달합니다. 이 예제에서는fs를 최종 입력 인수로 추가하여 샘플링 주파수를 48kHz로 지정합니다.>> BandPassSpecObj = ... fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2', ... F_stop1, F_pass1, F_pass2, F_stop2, A_stop1, A_pass, ... A_stop2, 48000)참고
필터의 차수는 지정되어 있지 않습니다. 따라서 사양을 충족하기 위해 알고리즘 설계에 자유도가 허용됩니다. 이 설계는 최소 차수 설계가 됩니다.
값을 지정하지 않을 경우 사양 파라미터(예:
Fstop1)는 모두 디폴트 값으로 지정됩니다. 필터 사양 객체가 생성된 후에 사양 파라미터의 값을 변경할 수 있습니다. 예를 들어, 두 개의 값Fpass2및Fstop2를 변경해야 할 경우,set명령을 사용합니다. 이 명령은 객체를 먼저 받은 다음 파라미터 값 쌍을 받습니다. MATLAB 프롬프트에서 다음 코드를 실행합니다.>> set(BandPassSpecObj, 'Fpass2', 15800, 'Fstop2', 18400)
BandPassSpecObj는 필터 유형을 비롯하여 필요한 모든 설계 파라미터를 포함하는 새 필터 사양 객체입니다.struct배열의 요소인 것처럼 필터 사양 객체의 파라미터 값에 액세스하여 값을 변경할 수도 있습니다.>> BandPassSpecObj.Fpass2=15800;
- 2단계
design명령을 사용하여 필터를 설계합니다.designmethods함수를 호출하여 사양 객체에 사용할 수 있는 설계 방법에 액세스할 수 있습니다. 예를 들어, 이 경우 다음 명령을 실행할 수 있습니다.특정 설계 방법을 사용하기로 선택한 후에는 MATLAB 프롬프트에서 다음을 실행할 수 있습니다(이 예제에서는 '>> designmethods(BandPassSpecObj) Design Methods for class fdesign.bandpass (Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2): butter cheby1 cheby2 ellip equiripple kaiserwin
equiripple'을 선택한 것으로 가정함).>> BandPassFilt = design(BandPassSpecObj, 'equiripple') BandPassFilt = FilterStructure: 'Direct-Form FIR' Arithmetic: 'double' Numerator: [1x44 double] PersistentMemory: falseDSP System Toolbox™가 설치되어 있는 경우에는 필터 System object™를 사용하여 필터를 설계할 수도 있습니다. 동일한 사양 객체
BandPassSpecObj를 사용하여 필터 System object를 생성하려면 다음 명령을 실행하면 됩니다.필터 System object에 사용 가능한 설계 방법과 설계 옵션이 필터 객체에 사용 가능한 설계 방법 및 설계 옵션과 반드시 같지는 않습니다.>> designmethods(BandPassSpecObj,... 'SystemObject',true) Design Methods that support System objects for class fdesign.bandpass (Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2): butter cheby1 cheby2 ellip equiripple kaiserwin >> BandPassFiltSysObj = design(BandPassSpecObj,... 'equiripple','SystemObject',true) System: dsp.FIRFilter Properties: Structure: 'Direct form' NumeratorSource: 'Property' Numerator: [1x44 double] InitialConditions: 0 FrameBasedProcessing: true Show fixed-point properties참고
설계 방법을 지정하지 않으면 디폴트 방법이 사용됩니다. 예를 들어, 다음 명령을 실행할 수 있습니다.
그러면 설계 방법이 자동으로 선택됩니다.>> BandPassFilt = design(BandPassSpecObj) BandPassFilt = FilterStructure: 'Direct-Form FIR' Arithmetic: 'double' Numerator: [1x44 double] PersistentMemory: false