Advanced Octave A44 — Filters and frequency response
Advanced GNU Octave with GX-TXT · Module 08
A filter does not only eliminate noise: change the amplitude and phase of the signal components. We analyze a simple moving average before entrusting it with a scientific interpretation.
Objectives and prerequisites
After the A43 sampling checks, we build a synthetic signal with sampling frequency 100 Hz and 3 and 25 Hz components. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import media_mobile.m, register it and run it in the Runner. The octave_advanced_filtered output dataset is created-only: to repeat, use a new session or change the ID.
Calculation and response
The causal filter uses five coefficients equal to 1/5: each output sample is the average of the last five available inputs, with zero initial conditions. filter applies the filter; the complex sum in the cycle calculates the response to the two frequencies. The NUMERIC_API_v1 API calculates the average output after the first four transient samples.
At 3 Hz the gain is about 0.9648 and the phase −0.3770 radians; at 25 Hz the gain is 0.2000 and the phase reported is 0 radians. The 25 Hz component, initially 0.4 V amplitude, is therefore 0.08 V wide. The answer depends on the frequency: the filter does not treat all components in the same way.
Delay and edge effects
The five coefficient symmetric FIR filter is delayed by group of two samples, i.e. 0.02 s to 100 Hz, where defined. The displayed phase is expressed in the main range and can be influenced by the signal changes of the response: do not deduce the delay by indiscriminately dividing each phase reported for the frequency. At first filter assumes zero previous values; the first four samples are affected by the initial conditions. Excluding them from statistics does not mean deleting them from the published Dataset.
For a real application, sample rate, useful band, phase response and transient must be checked. The filtered signal is a processed result: it also preserves the source and parameters of the filter.
Exercise
- What is the delay of two samples at 100 Hz?
- What amplitude remains of the 25 Hz synenoid in steady state?
- Why does the average in the program exclude the first four samples?
Worked solution
- 2/100 = 0.02 s.
- 0.4 × 0.2 = 0.08 V.
- In order not to include the transitory due to the initial conditions null in the summary; the choice must be documented.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories