Advanced Octave A62 — Typed parameters and configuration

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

Advanced GNU Octave with GX-TXT · Module 11

An explicit configuration makes an analysis repeatable and allows you to identify incompatible parameters before producing results. We compare two scenarios with the same sampling frequency.

Objectives and prerequisites

We repeat gxtxt_context of A06 and sampling of A43. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import configurazioni.m, register it and run it in the Runner.

Declare and verify

gxtxt_parameter_declare declares sample_rate as double, with default value 100 Hz and minimum 1 Hz. gxtxt_context() provides the actual value to the script. Two structures define scenarios at 2 and 8 Hz. Before calculating both, the program checks that each frequency is strictly less than half of the sampling frequency: if a configuration does not meet the condition, it signals an error before producing the summary of the scenarios.

This test controls the Nyquist condition for synthetic sinusoids of the example; it does not replace the evaluation of antialias filters and spectral content of a real signal.

With the default value, the test produces 100 samples in one second for both scenarios and RMS about 0.707107. The frequencies are different, but the RMS is the same in this case because the sinusoids have the same amplitude and the section contains a whole number of periods.

Reproducible configurations

Note the actual value of sample_rate, the name of the scenario and the parameters that determine the signal. A type statement does not verify all the physical relationships between parameters alone: those are to be controlled in the program, such as the ratio between signal frequency and sampling frequency.

Exercise

  1. What is the default sampling rate?
  2. Why are both scenarios verified before calculating them?
  3. Why are the two RMS of the test equal?

Worked solution

  1. 100 Hz.
  2. To avoid a partial summary when a configuration is incompatible.
  3. Synusoids have equal amplitude and the sample covers an entire number of periods.

Download the Module 11 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 *