# EmuFlight and INAV Matrix Filter

Matrix Filter will have its premiere together with **EmuFlight 0.3.0** and **INAV 2.5**. Which of those two will happen first is still unknown. After originally developing Matrix Filter for INAV, I also ported it to EmuFlight code and already some time ago they accepted my code proposal and merged it.

You have to admit, that the name is quite catchy. Matrix Filter for sure sounds very sci-fi. It's not that sci-fi tho. It's just an evolution of dynamic gyro notch filters known from Betaflight for quite some time. Instead of having a one-dimensional filter structure, it is a 3x3 filter matrix that works like this:

The base for dynamic gyro notches and Matrix Filter is an FFT (Fast Fourier Transform) gyro analysis that transforms the gyro signal from a time domain to a frequency domain. Thanks to this, the algorithm can simply pick the biggest frequency peak and setup and a notch filter (BSF - Band Stop Filter) on it.

This is how classical dynamic gyro filtering in Betaflight works. And usually, it works just fine. What if there are more peaks on one axis? What if the peak from X-axis manifests itself on Y-axis only with a lower amplitude?

Here comes the idea of a matrix filter. Each analyzed axis results in a notch filter on every other axis. Instead of having a "flat" structure of 3 filters, we have a total of 9. In the 3x3 matrix.

If X-axis FFT analysis identifies a peak frequency at, for example, 175Hz, a notch filter with a center frequency of 175Hz will be applied on X, Y and Z axes.

As a result, dynamic notches can cover a much wider area, still being fairly selective and with high enough Q factor to introduce as little phase delay as possible.

In-flight, the difference between Matrix Filter and RPM filter is very small. During my tests, I was not able to distinguish which one was enabled when. Both felt almost the same way.

I'm PaweÅ‚ Spychalski and I do things. Mainly software development, FPV drones and amateur cinematography. Here are my YouTube channels: