Main Content

Galería de diseño de filtros

Este ejemplo muestra cómo diseñar una variedad de filtros FIR e IIR digitales con la función designfilt en el producto Signal Processing Toolbox®.

La galería está diseñada para que identifique una respuesta de filtro de interés, vea el código y la utilice en su proyecto. Contiene ejemplos para cada respuesta de filtro disponible que ofrece designfilt. Observe, no obstante, que estas son solo unas pocas de las formas posibles de diseñar filtros para cada tipo de respuesta. Para ver una lista exhaustiva de conjuntos de especificaciones, consulte la documentación de Signal Processing Toolbox.

Excepto cuando se indique lo contrario, en este ejemplo todas las unidades de frecuencia se representan en hercios y todos los valores de ondulación y atenuación, en decibelios.

Filtros FIR paso bajo

Diseño equiripple

Fpass = 100;
Fstop = 150;
Apass = 1;
Astop = 65;
Fs = 1e3;
d1 = designfilt("lowpassfir", ...
    PassbandFrequency=Fpass, ...
    StopbandFrequency=Fstop, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation=Astop, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d1)

Filtros IIR paso bajo

Diseño lo más plano posible

Fpass = 100;
Fstop = 150;
Apass = 0.5;
Astop = 65;
Fs = 1e3;
d2 = designfilt("lowpassiir", ...
    PassbandFrequency=Fpass, ...
    StopbandFrequency=Fstop, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation=Astop, ...
    DesignMethod="butter", ...
    SampleRate=Fs);
filterAnalyzer(d2)

Ondulación en la banda de paso y en la banda de parada

N = 8;
Fpass = 100;
Apass = 0.5;
Astop = 65;
Fs = 1e3;
d3 = designfilt("lowpassiir", ...
    FilterOrder=N, ...
    PassbandFrequency=Fpass, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation=Astop, ...
    SampleRate=Fs);
filterAnalyzer(d3)

Filtros FIR paso alto

Diseño equiripple

Fstop = 350;
Fpass = 400;
Astop = 65;
Apass = 0.5;
Fs = 1e3;
d4 = designfilt("highpassfir", ...
    StopbandFrequency=Fstop, ...
    PassbandFrequency=Fpass, ...
    StopbandAttenuation=Astop, ...
    PassbandRipple=Apass, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d4)

Filtros IIR paso alto

Diseño lo más plano posible

Fstop = 350;
Fpass = 400;
Astop = 65;
Apass = 0.5;
Fs = 1e3;
d5 = designfilt("highpassiir", ...
    StopbandFrequency=Fstop ,...
    PassbandFrequency=Fpass, ...
    StopbandAttenuation=Astop, ...
    PassbandRipple=Apass, ...
    DesignMethod="butter", ...
    SampleRate=Fs);
filterAnalyzer(d5)

Ondulación en la banda de paso y en la banda de parada

N = 8;
Fpass = 400;
Astop = 65;
Apass = 0.5;
Fs = 1e3;
d6 = designfilt("highpassiir", ...
    FilterOrder=N, ...
    PassbandFrequency=Fpass, ...
    StopbandAttenuation=Astop, ...
    PassbandRipple=Apass, ...
    SampleRate=Fs);
filterAnalyzer(d6)

Filtros FIR paso banda

Diseño equiripple

Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Astop1 = 65;
Apass  = 0.5;
Astop2 = 65;
Fs = 1e3;
d7 = designfilt("bandpassfir", ...
    StopbandFrequency1=Fstop1, ...
    PassbandFrequency1=Fpass1, ...
    PassbandFrequency2=Fpass2, ...
    StopbandFrequency2=Fstop2, ...
    StopbandAttenuation1=Astop1, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation2=Astop2, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d7)

Atenuaciones de banda asimétricas

N = 50;
Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Wstop1 = 3;
Wstop2 = 100;
Fs = 1e3;
d8 = designfilt("bandpassfir", ...
    FilterOrder=N, ...
    StopbandFrequency1=Fstop1, ...
    PassbandFrequency1=Fpass1, ...
    PassbandFrequency2=Fpass2, ...
    StopbandFrequency2=Fstop2, ...
    StopbandWeight1=Wstop1,StopbandWeight2=Wstop2, ...
    DesignMethod="equiripple",SampleRate=Fs);
filterAnalyzer(d8)

Filtros IIR paso banda

Diseño lo más plano posible

Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Astop1 = 65;
Apass  = 0.5;
Astop2 = 65;
Fs = 1e3;
d9 = designfilt("bandpassiir", ...
    StopbandFrequency1=Fstop1, ...
    PassbandFrequency1=Fpass1, ...
    PassbandFrequency2=Fpass2, ...
    StopbandFrequency2=Fstop2, ...
    StopbandAttenuation1=Astop1, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation2=Astop2, ...
    DesignMethod="butter", ...
    SampleRate=Fs);
filterAnalyzer(d9)

Ondulación en la banda de paso y en la banda de parada

N = 8;
Fpass1 = 200;
Fpass2 = 300;
Astop1 = 65;
Apass  = 0.5;
Astop2 = 65;
Fs = 1e3;
d10 = designfilt("bandpassiir", ...
    FilterOrder=N, ...
    PassbandFrequency1=Fpass1, ...
    PassbandFrequency2=Fpass2, ...
    StopbandAttenuation1=Astop1, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation2=Astop2, ...
    SampleRate=Fs);
filterAnalyzer(d10)

Filtros FIR eliminadores de banda

Diseño equiripple

Fpass1 = 100;
Fstop1 = 150;
Fstop2 = 350;
Fpass2 = 400;
Apass1 = 0.5;
Astop  = 65;
Apass2 = 0.5;
Fs = 1e3;
d11 = designfilt("bandstopfir", ...
    PassbandFrequency1=Fpass1, ...
    StopbandFrequency1=Fstop1, ...
    StopbandFrequency2=Fstop2, ...
    PassbandFrequency2=Fpass2, ...
    PassbandRipple1=Apass1, ...
    StopbandAttenuation=Astop, ...
    PassbandRipple2=Apass2, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d11)

Ondulaciones de la banda de paso asimétricas

N = 30;
Fpass1 = 100;
Fstop1 = 150;
Fstop2 = 350;
Fpass2 = 400;
Wpass1 = 1;
Wpass2  = 10;
Fs = 1e3;
d12 = designfilt("bandstopfir", ...
    FilterOrder=N, ...
    PassbandFrequency1=Fpass1, ...
    StopbandFrequency1=Fstop1, ...
    StopbandFrequency2=Fstop2, ...
    PassbandFrequency2=Fpass2, ...
    PassbandWeight1=Wpass1, ...
    PassbandWeight2=Wpass2, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d12)

Filtros IIR eliminadores de banda

Diseño lo más plano posible

Fpass1 = 100;
Fstop1 = 150;
Fstop2 = 350;
Fpass2 = 400;
Apass1 = 0.5;
Astop  = 65;
Apass2 = 0.5;
Fs = 1e3;
d13 = designfilt("bandstopiir", ...
    PassbandFrequency1=Fpass1, ...
    StopbandFrequency1=Fstop1, ...
    StopbandFrequency2=Fstop2, ...
    PassbandFrequency2=Fpass2, ...
    PassbandRipple1=Apass1, ...
    StopbandAttenuation=Astop, ...
    PassbandRipple2=Apass2, ...
    DesignMethod="butter", ...
    SampleRate=Fs);
filterAnalyzer(d13)

Ondulación en la banda de paso y en la banda de parada

N = 8;
Fpass1 = 125;
Fpass2 = 375;
Apass = 0.5;
Astop  = 65;
Fs = 1e3;
d14 = designfilt("bandstopiir", ...
    FilterOrder=N, ...
    PassbandFrequency1=Fpass1, ...
    PassbandFrequency2=Fpass2, ...
    PassbandRipple=Apass, ...
    StopbandAttenuation=Astop, ...
    SampleRate=Fs);
filterAnalyzer(d14)

Filtros FIR de magnitud arbitraria

Diseño de magnitud arbitraria de banda única

N = 300;
% Frequencies are in normalized units
F1 = 0:0.01:0.18;
F2 = [0.2 0.38 0.4 0.55 0.562 0.585 0.6 0.78];
F3 = 0.79:0.01:1;
FreqVect = [F1 F2 F3]; % vector of frequencies
% Define desired response using linear units
A1 = 0.5+sin(2*pi*7.5*F1)/4;    % Sinusoidal section
A2 = [0.5 2.3 1 1 -0.2 -0.2 1 1]; % Piece-wise linear section
A3 = 0.2+18*(1-F3).^2;          % Quadratic section
AmpVect = [A1 A2 A3];
d15 = designfilt("arbmagfir",...
    FilterOrder=N, ...
    Amplitudes=AmpVect, ...
    Frequencies=FreqVect,...
    DesignMethod="freqsamp");
filterAnalyzer(d15,MagnitudeMode="zerophase")

Diseño paso bajo multibanda con niveles de atenuación escalonada en la banda de parada

N = 150;
B = 2; % Number of bands
% Frequencies are in normalized units
F1 = [0 0.25]; % Passband
F2 = [0.3 0.4 0.401 0.5 0.501 0.6 0.601 0.7 0.701 0.8 0.801 0.9 0.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
d16 = designfilt("arbmagfir", ...
    FilterOrder=N, ...
    NumBands=B, ...
    BandFrequencies1=F1, ...
    BandAmplitudes1=A1, ...
    BandFrequencies2=F2, ...
    BandAmplitudes2=A2, ...
    BandWeights1=W1, ...
    BandWeights2=W2);
filterAnalyzer(d16)

Filtros FIR diferenciadores

Diseño de banda completa

N = 41;
Fs = 1e3;
d17 = designfilt("differentiatorfir", ...
    FilterOrder=N, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d17,MagnitudeMode="zerophase",OverlayAnalysis="phase")

Diseño de banda parcial

N = 40;
Fpass = 100;
Fstop = 150;
Fs = 1e3;
d18 = designfilt("differentiatorfir", ...
    FilterOrder=N, ...
    PassbandFrequency=Fpass, ...
    StopbandFrequency=Fstop, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d18,MagnitudeMode="zerophase",OverlayAnalysis="phase")

Filtros FIR de Hilbert

Diseño equiripple

N = 40;
Tw = 50;
Fs = 1e3;
d19 = designfilt("hilbertfir", ...
    FilterOrder=N, ...
    TransitionWidth=Tw, ...
    DesignMethod="equiripple", ...
    SampleRate=Fs);
filterAnalyzer(d19,MagnitudeMode="zerophase",OverlayAnalysis="phase")

Consulte también

|