zp =filter(analogFilter, filterType, order, f_cut, gain, A_ripple, normalized);

This function constructs a ZerosAndPoles transfer function description of low and high pass filters. For more details see also [Tietze2002], pp. 815-852.

Typical frequency responses for the 4 supported low pass filter types are shown in the next figure (this figure was generated with function Examples.ZerosAndPoles.plotBodeFilter2):

The step responses of the same low pass filters are shown in the next figure, starting from a steady state initial filter with initial input = 0.2:

Obviously, the frequency responses give a somewhat wrong impression of the filter characteristics: Although Butterworth and Chebyshev filters have a significantly steeper magnitude as the CriticalDamping and Bessel filters, the step responses of the latter ones are much better. This means for example, that a CriticalDamping or a Bessel filter should be selected, if a filter is mainly used to make a non-linear inverse model realizable.

Typical frequency responses for the 4 supported high pass filter types are shown in the next figure:

The corresponding step responses of these high pass filters are shown in the next figure:

All filters are available in **normalized** (default) and
non-normalized form. In the normalized form, the amplitude of the
filter transfer function at the cutoff frequency is 3 dB. Note,
when comparing the filters of this function with other software
systems, the setting of "normalized" has to be selected
appropriately. For example, the signal processing toolbox of Matlab
provides the filters in non-normalized form and therefore a
comparison makes only sense, if normalized = **false** is
set.

Types.AnalogFilter analogFilter=Types.AnalogFilter.CriticalDamping; Integer order=2; Modelica.Units.SI.Frequency f_cut=10; ZerosAndPoles zp_filter;algorithmzp_filter=Modelica_LinearSystems2.ZerosAndPoles.Design.filter( order=order, f_cut=f_cut, analogFilter=analogFilter); // zp_filter = 9530.93/( (p + 97.6265)^2 )

encapsulated function filter import Modelica; import Modelica.Utilities.Streams; import Modelica_LinearSystems2; import Modelica_LinearSystems2.Utilities.Types; import Modelica_LinearSystems2.ZerosAndPoles; input Modelica_LinearSystems2.Utilities.Types.AnalogFilter analogFilter = Modelica_LinearSystems2.Utilities.Types.AnalogFilter.CriticalDamping "Analog filter characteristics (CriticalDamping/Bessel/Butterworth/Chebyshev)"; input Modelica_LinearSystems2.Utilities.Types.FilterType filterType = Modelica_LinearSystems2.Utilities.Types.FilterType.LowPass "Type of filter (LowPass/HighPass/BandPass)"; input Integer order(min = 1) = 2 "Order of filter"; input Modelica.Units.SI.Frequency f_cut = 1 / (2 * Modelica.Constants.pi) "Cut-off frequency (default is w_cut = 1 rad/s)"; input Real gain = 1.0 "Gain (= amplitude of frequency response at zero frequency)"; input Real A_ripple(unit = "dB") = 0.5 "Pass band ripple (only for Chebyshev filter)"; input Boolean normalized = true "True, if amplitude at f_cut = -3db*gain"; input Modelica.Units.SI.Frequency f_min = 0 "Band of normalized band pass/stop filter is f_min (-3db*gain) .. f_cut (-3db*gain)"; output ZerosAndPoles filter(redeclare Real n1[if filterType == Types.FilterType.BandPass then order else if filterType == Types.FilterType.HighPass then if analogFilter == Types.AnalogFilter.CriticalDamping then order else mod(order, 2) else 0], redeclare Real n2[if filterType == Types.FilterType.BandStop then order else if filterType == Types.FilterType.HighPass and analogFilter <> Types.AnalogFilter.CriticalDamping then integer(order / 2) else 0, 2], redeclare Real d1[if filterType == Types.FilterType.BandPass or filterType == Types.FilterType.BandStop then 0 else if analogFilter == Types.AnalogFilter.CriticalDamping then order else mod(order, 2)], redeclare Real d2[if filterType == Types.FilterType.BandPass or filterType == Types.FilterType.BandStop then order else if analogFilter == Types.AnalogFilter.CriticalDamping then 0 else integer(order / 2), 2]) "Filter transfer function"; end filter;

Generated at 2020-07-12T01:53:50Z by OpenModelicaOpenModelica 1.16.0~dev-548-gd3091d6 using GenerateDoc.mos