Галерея Filter Design

В этом примере показано, как спроектировать разнообразие КИХ и БИХ-цифровых фильтров с designfilt функция в продукте Signal Processing Toolbox®.

Галерея спроектирована для вас, чтобы идентифицировать ответ фильтра интереса, просмотреть код и использовать его в вашем собственном проекте. Это содержит примеры для каждого из доступных ответов фильтра, предлагаемых designfilt. Обратите внимание, однако, что это только несколько возможных путей, которыми можно спроектировать фильтры для каждого типа ответа. Для исчерпывающего списка наборов спецификации см. документацию Signal Processing Toolbox.

Кроме тех случаев, когда отмеченный в противном случае, в этом примере все единицы частоты находятся в герц, и вся пульсация и значения затухания находятся в децибелах.

КИХ-фильтры lowpass

Проект Equiripple

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

БИХ-фильтры lowpass

Максимально плоский проект

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

КИХ-фильтры Highpass

Проект Equiripple

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

БИХ-фильтры Highpass

Максимально плоский проект

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

Полосовые КИХ-фильтры

Проект Equiripple

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

Полосовые БИХ-фильтры

Максимально плоский проект

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

КИХ-фильтры Bandstop

Проект Equiripple

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

БИХ-фильтры Bandstop

Максимально плоский проект

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

Произвольные КИХ-фильтры величины

Одно полоса произвольный проект величины

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 Filter Visualization Tool - Zero-phase Response contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Zero-phase Response contains 2 objects of type line.

Многополосный проект Lowpass со ступенчатыми уровнями затухания на полосе задерживания

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 Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

КИХ-фильтры дифференциатора

Полный проект полосы

N = 41;
Fs = 1e3;

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

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

Figure Filter Visualization Tool - Zero-phase Response and Phase Response contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Zero-phase Response and Phase Response 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 Filter Visualization Tool - Zero-phase Response and Phase Response contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Zero-phase Response and Phase Response contains an object of type line.

Гильбертовы КИХ-фильтры

Проект Equiripple

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 Filter Visualization Tool - Zero-phase Response and Phase Response contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Zero-phase Response and Phase Response contains an object of type line.

Смотрите также

|

Для просмотра документации необходимо авторизоваться на сайте