Generated reference › Band Power — Control Systems/Spectral Measurements
kind: generated#block#control-systems-spectral-measurements

Band Power — Control Systems/Spectral Measurements

Control_Systems/Spectral_Measurements/Band_Power · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Band Power

Control Systems / Spectral Measurements

The average power a power spectral density carries, either over the whole spectrum or over one frequency band – P = Σk wk·pk, a rectangle rule over the bins. Bin k sits at frequency fk = k·Δ, and the weights wk are the bin widths the range rule assigns. This is the streaming counterpart of MATLAB's bandpower(Pxx, F, 'psd').

The weights follow from the parameters alone, so the block is one weighted sum: no division, no branch and nothing carried between samples.

Ports

  • p – the power spectral density, one nonnegative value per bin. A vector, either an [N,1] column or a [1,N] row, with N between 2 and 512. Bin k is the frequency k·Δ.
  • P – the power in the selected range. Always scalar, whatever the input's length.

Parameters

  • Bin Spacing – Δ, the frequency step between neighbouring bins, a positive number. Left at 1 the answer is a power per bin; set it to fs÷(2·(N−1)) for a one-sided spectrum reaching the Nyquist frequency, and the answer is a power in the signal's own units.
  • Integration Range – which bins are summed, and which of two rectangle rules is used:
    • Full spectrum – every bin, each given the width Δ. This is bandpower(Pxx, F, 'psd'), and it is the default.
    • Frequency band – only the bins the band reaches, and the top bin of the whole vector is given a width of zero. This is bandpower(Pxx, F, [flo fhi], 'psd'). See Notes: over the same full axis the two modes deliberately do not agree.
  • Frequency Band – [flo fhi], a two element vector in the same units as Bin Spacing, read only in Frequency band mode. The band is widened to the bins that bracket it: the sum starts at the last bin at or below flo and ends at the first bin at or above fhi.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text.

The N weights are structural and are inlined into the arithmetic at export time rather than exposed as tunable parameters – they follow from the bin spacing, the bin count and the band, and changing any of them changes how many multiplies the core contains, which no runtime parameter can do. Re-export after changing them.

The three HDL targets are genuine synthesizable Q16.16: a fixed multiply-accumulate with the products accumulated at full width and shifted back once at the end rather than per term. There is nothing in this block to make simulation-only – it neither divides nor takes a root.

Simulink bridge

No equivalent (Support::None). Signal Processing Toolbox ships no Simulink library at all, and bandpower is one of its MATLAB functions. DSP System Toolbox was searched block by block and carries nothing that integrates a PSD over a band: its Power Meter measures the average or peak power of a time signal against a reference load, which is a different measurement on a different input. The bridge reports this block rather than dropping it silently, and it therefore has no parity testbench. Code export verification still covers it across all ten languages.

Notes

  • Stateless. The answer depends on this sample's spectrum and nothing else, so there is no startup transient and no history to seed.
  • The two range modes deliberately do not agree on the same axis. Over the full spectrum the top bin is given the average bin spacing; over a band it is given a width of zero, which is MATLAB's own rule (bandpower.m: "Don't include last point of PSD data"). Measured on an 8-bin spectrum at Δ = 0.5, R2026a answers 2.835 over the full spectrum and 2.8 over the band [0, 3.5] – the same axis, one bin apart. Reproduced here to the last bit.
  • The band is widened, not narrowed. A band falling between bins is snapped outward to the bins that bracket it. Mean Frequency snaps the other way and keeps only the bins that lie inside the band. Both are MATLAB's, on the same PSD, and neither is a rounding of the other – so the two blocks can legitimately report a band's power and its mean frequency over different sets of bins.
  • The input is expected nonnegative. A power spectral density is, and nothing here checks it: a negative bin is summed like any other, which is the right behaviour for a user who is integrating something else with the same rectangle rule.
  • No state space. The block is linear in its input, but it reduces a vector to a scalar rather than evolving a state, so it carries none and model reduction correctly declines to merge it.

Code facts#

FactValue
registered typeControl_Systems/Spectral_Measurements/Band_Power
familyControl_Systems/Spectral_Measurements
solver environment classICoreBlock_0_Control_Systems_1_Spectral_Measurements_2_Band_Power
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Spectral_Measurements/Band_Power/ICoreBlock_0_Control_Systems_1_Spectral_Measurements_2_Band_Power.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Spectral_Measurements/Band_Power/ICoreBlock_0_Control_Systems_1_Spectral_Measurements_2_Band_Power.h
default size on canvas128 × 72 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublep
2outICoreDoubleP

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Bin Spacing1—
Integration RangeFull spectrum%~%Frequency band~~Full spectrum—
Frequency Band[0 1]—

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no Simulink equivalent: bandpower() is a MATLAB function and Signal Processing Toolbox ships no Simulink library at all. DSP System Toolbox was searched block by block and integrates no PSD over a band -- its Power Meter measures the average or peak power of a TIME signal against a reference load, a different measurement on a different input. Reported rather than dropped, and it carries no parity testbench

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 every stimulus in the sample errored — cross-checks skipped

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Band Power -- the average power carried by a power spectral density, over the whole spectrum or over one frequency band. ONE WEIGHT VECTOR, TEN IDENTICAL DOT PRODUCTS. The rectangle rule's widths follow from the bin spacing, the bin count and the band alone -- all settled before the run starts -- so they are derived once when the configuration is read and every target inlines the same multiply-accumulate. The emitted core has no division and no branch, which is what keeps the three hardware targets a genuine fixed-point pipeline rather than a simulation.

TRANSCRIBED FROM R2026a's bandpower.m, and every rule below was checked against a run of it rather than inferred. On the 8-bin spectrum

p = [0.12 0.85 2.40 1.10 0.35 0.60 0.18 0.07] at Delta = 0.5

R2026a answers 2.835 over the full spectrum, 2.8 over the band [0, 3.5] (which is the whole axis), 2.74 over [0.6, 2.9] and 2.65 over [0.5, 2.5]. This block reproduces all four to the last bit.

⚠ THE FULL AND BANDED RULES DIFFER IN THE LAST BIN. bandpower.m gives the top bin the average bin spacing over the full spectrum and a width of ZERO over a band -- its own comment is "Don't include last point of PSD data" -- which is why the full and whole-axis answers above are not the same number.

⚠ THE BAND IS SNAPPED OUTWARD. The sum runs from the last bin at or below flo to the first bin at or above fhi, so a band falling between bins is widened to the bins bracketing it. Mean Frequency snaps the other way, keeping only the bins inside the band. Both conventions are in one toolbox, on the same PSD.

Sample results#

No stimulus produced a sampled output in this rig — Invalid input size at: ICore Blocks/Home/Band Power. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.

Category unsampled · sample time 0.1 · 60 steps · commit b639d6540 · produced by docsSample --out <folder> --blocks Band_Power Mean_Frequency --steps 60

Sample data: docs/generated/samples/Control_Systems__Spectral_Measurements__Band_Power.json