Advanced Octave A44 — Filters and frequency response

by Giux GX-TXT, octave-en, scripts-en 2 min read

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

  1. What is the delay of two samples at 100 Hz?
  2. What amplitude remains of the 25 Hz synenoid in steady state?
  3. Why does the average in the program exclude the first four samples?

Worked solution

  1. 2/100 = 0.02 s.
  2. 0.4 × 0.2 = 0.08 V.
  3. In order not to include the transitory due to the initial conditions null in the summary; the choice must be documented.

Download the Module 08 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *