filters-matlab-bank/index.org
2019-08-17 10:50:06 +02:00

32 KiB

List of filters - Matlab Implementation

Proportional - Integral - Derivative

Proportional

Integral

Derivative

Low Pass

First Order

\[ H(s) = \frac{1}{1 + s/\omega_0} \]

  w0 = 2*pi; % [rad/s]

  H = 1/(1 + s/w0);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/lpf_first_order.png

First Order Low Pass Filter (png, pdf.

Second Order

\[ H(s) = \frac{1}{1 + 2 \xi / \omega_0 s + s^2/\omega_0^2} \]

  w0 = 2*pi; % [rad/s]
  xi = 0.3;

  H = 1/(1 + 2*xi/w0*s + s^2/w0^2);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/lpf_second_order.png

Second Order Low Pass Filter (png, pdf.

Combine multiple filters

\[ H(s) = \left( \frac{1}{1 + s/\omega_0} \right)^n \]

  w0 = 2*pi; % [rad/s]
  n = 3;

  H = (1/(1 + s/w0))^n;

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/lpf_multiple_first_order.png

Combine Multiple First Order Low Pass Filter (png, pdf.

Nice combination

\begin{equation} W(s) = G_c * \left(\frac{\frac{1}{\omega_0}\sqrt{\frac{1 - \left(\frac{G_0}{G_c}\right)^{\frac{2}{n}}}{1 - \left(\frac{G_c}{G_\infty}\right)^{\frac{2}{n}}}} s + \left(\frac{G_0}{G_c}\right)^{\frac{1}{n}}}{\frac{1}{\omega_0} \sqrt{\frac{1 - \left(\frac{G_0}{G_c}\right)^{\frac{2}{n}}}{\left(\frac{G_\infty}{G_c}\right)^{\frac{2}{n}} - 1}} s + 1}\right)^n \end{equation}
  n = 2; w0 = 2*pi*11; G0 = 1/10; G1 = 1000; Gc = 1/2;
  wL = Gc*(((G1/Gc)^(1/n)/w0*sqrt((1-(G0/Gc)^(2/n))/((G1/Gc)^(2/n)-1))*s + (G0/Gc)^(1/n))/(1/w0*sqrt((1-(G0/Gc)^(2/n))/((G1/Gc)^(2/n)-1))*s + 1))^n;

  n = 3; w0 = 2*pi*9; G0 = 10000; G1 = 0.1; Gc = 1/2;
  wH = Gc*(((G1/Gc)^(1/n)/w0*sqrt((1-(G0/Gc)^(2/n))/((G1/Gc)^(2/n)-1))*s + (G0/Gc)^(1/n))/(1/w0*sqrt((1-(G0/Gc)^(2/n))/((G1/Gc)^(2/n)-1))*s + 1))^n;

High Pass

First Order

\[ H(s) = \frac{s/\omega_0}{1 + s/\omega_0} \]

  w0 = 2*pi; % [rad/s]

  H = (s/w0)/(1 + s/w0);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/hpf_first_order.png

First Order High Pass Filter (png, pdf.

Second Order

\[ H(s) = \frac{s^2/\omega_0^2}{1 + 2 \xi / \omega_0 s + s^2/\omega_0^2} \]

  w0 = 2*pi; % [rad/s]
  xi = 0.3;

  H = (s^2/w0^2)/(1 + 2*xi/w0*s + s^2/w0^2);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/hpf_second_order.png

Second Order High Pass Filter (png, pdf.

Combine multiple filters

\[ H(s) = \left( \frac{s/\omega_0}{1 + s/\omega_0} \right)^n \]

  w0 = 2*pi; % [rad/s]
  n = 3;

  H = ((s/w0)/(1 + s/w0))^n;

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/hpf_multiple_first_order.png

Combine Multiple First Order High Pass Filter (png, pdf.

Band Pass

Notch

Chebyshev

Chebyshev Type I

  n = 4; % Order of the filter
  Rp = 3; % Maximum peak-to-peak ripple [dB]
  Wp = 2*pi; % passband-edge frequency [rad/s]

  [A,B,C,D] = cheby1(n, Rp, Wp, 'high', 's');
  H = ss(A, B, C, D);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/cheby1_hpf.png

First Order Low Pass Filter (png, pdf.

Lead - Lag

Lead

\[ H(s) = \frac{1 + s/\omega_z}{1 + s/\omega_p}, \quad \omega_z < \omega_p \]

  • Find a nice parametrisation to be able to specify the center frequency and the phase added
  • Compute also the change in magnitude
  h = 2.0;
  wz = 2*pi/h; % [rad/s]
  wp = 2*pi*h; % [rad/s]

  H = (1 + s/wz)/(1 + s/wp);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/lead_filter.png

Lead Filter (png, pdf.

Lag

\[ H(s) = \frac{1 + s/\omega_z}{1 + s/\omega_p}, \quad \omega_z > \omega_p \]

  • Find a nice parametrisation to be able to specify the center frequency and the phase added
  • Compute also the change in magnitude
  h = 2.0;
  wz = 2*pi*h; % [rad/s]
  wp = 2*pi/h; % [rad/s]

  H = (1 + s/wz)/(1 + s/wp);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/lag_filter.png

Lag Filter (png, pdf.

Lead Lag

\[ H(s) = \frac{1 + s/\omega_z}{1 + s/\omega_p} \frac{1 + s/\omega_z}{1 + s/\omega_p}, \quad \omega_z > \omega_p \]

  wz1 = 2*pi*1; % [rad/s]
  wp1 = 2*pi*0.1; % [rad/s]
  wz2 = 2*pi*10; % [rad/s]
  wp2 = 2*pi*20; % [rad/s]

  H = (1 + s/wz1)/(1 + s/wp1)*(1 + s/wz2)/(1 + s/wp2);

/tdehaeze/filters-matlab-bank/media/commit/feff71de742e956971fa1b44855b1a5bbbb9408b/figs/lead_lag_filter.png

Lead Lag Filter (png, pdf.

Complementary

Combine Filters

Additive

  • Explain how phase and magnitude combine

Multiplicative