# Optimisation of a filter knowing input and output

7 views (last 30 days)
RefLulu on 15 Sep 2019
Answered: Walter Roberson on 16 Sep 2019
Dear all,
I have two array of data. One represents a signal y, and the other represents a signal x;
I know that y is linked to x with a first order low pass filter signal ( but I don't know its characteristics such as gain,... ).
Thus, I would like to know : How to compute the coefficient of the filter w.r.t the knowledge of y and x ?
Thanks for all ! :)

Star Strider on 15 Sep 2019
The System identification Toolbox is dedicated to problems like this.
See if the Signal Processing Toolbox invfreqz function will do what you want.

Walter Roberson on 16 Sep 2019
First order low pass filters only have a very small number of parameters. If you look at the discrete description at https://en.wikipedia.org/wiki/Low-pass_filter#Discrete-time_realization then it can be modeled in terms of the angular cutoff and the sampling period (see also https://dsp.stackexchange.com/questions/43063/first-order-low-pass-filter )
If you have a fixed sampling period, then you have a simple non-linear optimization in one variable: find the angular cutoff that minimizes the sum of squares of differences between the desired output on the sample signal and the output that would be modeled by using that angular cutoff. You can have your function create a tf() and run the signal through, calculate the SSE, and return it, and use fminbnd() on the function over the range [0 1] . With that in hand, you would convert the normalized cutoff frequency to non-normalized by multiplying by Fs/2