Advanced Octave A47 — Spectrograms and varying frequencies

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

Advanced GNU Octave with GX-TXT · Module 08

A FFT on the entire signal indicates which frequencies are present, but hides when they appear. We analyze a signal whose frequency grows over time with a transformation on overlapping windows.

Objectives and prerequisites

We repeat the normalization of A45 PSD and the three-dimensional surface of A41. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import chirp_stft.m, register it and run it in the Runner. The Dataset octave_advanced_chirp_stft is created-only: to repeat the example, use a new Session or change the ID.

Windows and transformed

The synthetic signal is sin(2*pi*(5*t+2.5*t.^2)), a 128 Hz championship for 512 champions. The instant frequency is the result of the phase in cycles: it grows from 5 Hz to 25 Hz. The script applies a window of Hann of 64 samples, calculates a one-sided PSD for each tract and advances 16 samples between one stroke and the next.

There are 29 0.5 s windows, with 0.125 s timeframe. The spacing of the frequency points is 2 Hz; the actual width of the components depends also on the window. The matrix contains 33 frequencies per window, i.e. 957 values. The temporal center of each window is associated with its spectrum. As in A41, all coordinates and values are transformed into columns with the same order before publication.

Interpreting the figure

The script creates a surface with time in seconds, frequency in hertz and PSD in V²/Hz. Open the variant from Plots, double-click and use Fit:

The crest shows how the power distribution moves along the frequency over time. The reticle and perspective influence the displayed form: the vertices are based on the estimates of the windows, not on a continuous measure between them. The automatic margins of the axes can extend slightly beyond the coordinates of the samples.

A longer window reduces frequency point spacing, but describes a wider time interval; a shorter location better changes over time and has more distant frequency points. Also overlap and type of window must be declared.

Exercise

  1. How long does every window last from 64 samples to 128 Hz?
  2. How much are the next windows calculated?
  3. Why does PSD change location in frequency?

Worked solution

  1. 64/128 = 0.5 s.
  2. 16/128 = 0.125 s.
  3. The chirp is constructed with increasing instantaneous frequency: later windows look at strokes at different frequencies.

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 *