Skip to content

Simba.Data

Simba.Data.Analysis

SignalMatExport

Builds and writes the .mat variables of a set of signals (issue #102). - Shared X axis (HaveIdenticalXAxis(IReadOnlyList)): one X variable named after the axis (time, frequency...), then one variable per signal, named after the signal. - Different X axes: two variables per signal, x_<signal> and y_<signal>. Nothing is resampled or interpolated.

Units are not written: MATLAB variables have no unit, and a unit in the name would make names change with the unit.

Fields
EmptyNameReplacement Name used for a signal (or an axis) whose name has no usable character.
InvalidStartPrefix Prefix added to a name that does not start with a letter, or that is a MATLAB keyword.
Methods
BuildVariables(IReadOnlyList) Returns the variables written for signals, in file order.
HaveIdenticalXAxis(IReadOnlyList) True when every signal has exactly the same X axis: the same axis name and unit (ordinal comparison), the same number of exported points, and the same values, compared exactly (System.Double.Equals(System.Double), so two NaN are equal and 0 equals -0). No tolerance on purpose: two time bases that differ by rounding come from different runs or steps, and sharing one X between them would silently move points.
ToMatlabName(string) Turns any text into a valid MATLAB variable name: every character other than an ASCII letter, digit or underscore becomes _, runs of _ collapse to one, and leading or trailing _ are removed ("DC1 - Voltage" gives DC1_Voltage). A name that is then empty becomes EmptyNameReplacement; one that starts with a digit, or is a MATLAB keyword, gets the prefix InvalidStartPrefix ("1st" gives sig_1st). The result is cut to MaxVariableNameLength characters. It is not made unique here.
Write(Stream, IReadOnlyList, DateTime) Writes the .mat file of signals to stream.
WriteFile(string, IReadOnlyList) Writes signals to a MAT file, replacing the destination only after a successful write. Desktop and Python callers should apply their export permission checks before calling.
WriteSignals(Stream, IReadOnlyList, DateTime) Writes signals using their own time or frequency axes. Sampled axes are reconstructed from FirstSampleTime and SamplingTime; compressed scopes retain their saved X/Y points.