-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference: Utilities
Supporting classes and functions used across the FastPlot library.
Hierarchical console progress bar with Unicode/ASCII rendering. Used internally by FastPlot, FastPlotFigure, and FastPlotDock during rendering. Can also be used standalone.
pb = ConsoleProgressBar(); % No indentation
pb = ConsoleProgressBar(2); % 2-space indent (for nested progress)All properties have Access = private.
| Property | Type | Default | Description |
|---|---|---|---|
| Label | char | '' |
Current text label (max 12 chars displayed) |
| Current | double | 0 | Current progress count |
| Total | double | 0 | Total progress count |
| BarWidth | double | 30 | Character width of the progress bar |
| Indent | double | 0 | Number of leading spaces for nesting |
| IsStarted | logical | false | Whether start() has been called |
| IsFrozen | logical | false | Whether the bar is frozen (permanent) |
| LastLen | double | 0 | Character count of last printed line (for backspace) |
Initialize and render the empty progress bar. Resets frozen/started state and prints the initial bar.
pb = ConsoleProgressBar();
pb.start();Update progress. Optionally set a label (labels longer than 12 characters are truncated). Has no visible effect if the bar has not been started or has already been frozen.
pb.update(3, 10); % 30% complete
pb.update(3, 10, 'Processing...'); % 30% with labelMake the current state permanent (prints newline so bar is not overwritten). Subsequent calls to update() are silently ignored. Does nothing if the bar was never started or is already frozen.
pb.freeze();Set to 100%, freeze, and mark as done. Sets IsStarted to false. Does nothing if the bar was never started.
pb.finish();-
MATLAB: Unicode block characters (
U+2588full block andU+2591light shade) for smooth progress -
GNU Octave: ASCII characters (
#and-) for compatibility
The bar redraws in-place using backspace characters (\b) to erase the previous line, avoiding flicker and keeping output on a single console line.
pb = ConsoleProgressBar();
pb.start();
for i = 1:100
pause(0.01);
pb.update(i, 100, sprintf('Step %d', i));
end
pb.finish();% Parent progress bar
parentPB = ConsoleProgressBar();
parentPB.start();
for i = 1:3
parentPB.update(i-1, 3, sprintf('Tab %d', i));
% Child progress bar (indented)
childPB = ConsoleProgressBar(2);
childPB.start();
for j = 1:5
pause(0.01);
childPB.update(j, 5, sprintf('Tile %d', j));
end
childPB.finish();
end
parentPB.finish();This is how FastPlotDock.renderAll() displays hierarchical progress across tabs and tiles.
Function that returns a struct of global default configuration values. All FastPlot, FastPlotFigure, and FastPlotDock instances inherit these defaults unless overridden at construction.
Values are loaded once per MATLAB session via getDefaults() and cached in a persistent variable. Call clearDefaultsCache() to force a reload after editing this file.
defaults = FastPlotDefaults();| Field | Type | Default | Description |
|---|---|---|---|
| Theme | char | 'default' |
Preset name ('default', 'dark', 'light', 'industrial', 'scientific') or a struct of theme overrides |
| ThemeDir | char | 'themes' |
Folder containing custom theme .m files, relative to FastPlotDefaults.m |
| Verbose | logical | false |
Print diagnostic messages to the console during plotting operations |
| Field | Type | Default | Description |
|---|---|---|---|
| MinPointsForDownsample | double | 5000 | Below this, plot raw data without downsampling |
| DownsampleFactor | double | 2 | Points per pixel for downsampling; higher values produce denser traces |
| PyramidReduction | double | 100 | Compression factor per level of the data pyramid; controls ratio between successive LOD levels |
| Field | Type | Default | Description |
|---|---|---|---|
| DefaultDownsampleMethod | char | 'minmax' |
Downsampling algorithm: 'minmax' preserves extremes, 'lttb' (Largest-Triangle-Three-Buckets) preserves visual shape |
| Field | Type | Default | Description |
|---|---|---|---|
| XScale | char | 'linear' |
Default X-axis scale ('linear' or 'log') |
| YScale | char | 'linear' |
Default Y-axis scale ('linear' or 'log') |
| Field | Type | Default | Description |
|---|---|---|---|
| LiveInterval | double | 2.0 | Polling interval in seconds for live-updating data sources |
| Field | Type | Default | Description |
|---|---|---|---|
| DashboardPadding | 1x4 double | [0.06 0.04 0.01 0.02] |
Edge padding [left bottom right top]
|
| DashboardGapH | double | 0.03 | Horizontal gap between adjacent tiles |
| DashboardGapV | double | 0.06 | Vertical gap between adjacent tiles |
| Field | Type | Default | Description |
|---|---|---|---|
| TabBarHeight | double | 0.03 | Normalized height of the tab bar in docked figure mode |
Edit FastPlotDefaults.m directly to change project-wide defaults:
function defaults = FastPlotDefaults()
defaults.Theme = 'dark'; % Change default theme
defaults.DownsampleFactor = 3; % More points per pixel
defaults.LiveInterval = 1.0; % Faster polling
% ...
endCall clearDefaultsCache() to force a reload after editing FastPlotDefaults.m:
clearDefaultsCache();Fast binary search for finding an index in a sorted array. Available as both a pure-MATLAB function and a MEX-accelerated version (binary_search_mex). The MEX availability check is performed once per session and cached in a persistent variable.
idx = binary_search(x, val, 'left'); % First index where x(idx) >= val
idx = binary_search(x, val, 'right'); % Last index where x(idx) <= val| Parameter | Type | Description |
|---|---|---|
| x | 1xN double | Sorted (monotonically increasing) array |
| val | double | Scalar value to search for |
| direction | char |
'left' for lower-bound (first index where x(idx) >= val) or 'right' for upper-bound (last index where x(idx) <= val) |
| idx | double | Positive integer index, always clamped to [1, numel(x)]
|
x = [1 3 5 7 9 11];
binary_search(x, 6, 'left') % returns 4 (x(4) = 7 >= 6)
binary_search(x, 6, 'right') % returns 3 (x(3) = 5 <= 6)Performance: O(log N) time complexity with O(1) auxiliary space vs O(N) for find(). The MEX version (binary_search_mex) provides additional speedup.
Script to compile all C MEX accelerators. Auto-detects architecture, selects the best available compiler, and sets appropriate SIMD flags.
cd libs/FastPlot
build_mex();| Source File | Description |
|---|---|
binary_search_mex.c |
O(log n) binary search on sorted arrays |
minmax_core_mex.c |
SIMD MinMax downsampling kernel |
lttb_core_mex.c |
SIMD Largest-Triangle-Three-Buckets kernel |
violation_cull_mex.c |
Fused threshold violation detection + pixel culling |
Source files are located in private/mex_src/ and compiled outputs go to private/.
The function normalizes platform strings from MATLAB (maca64, maci64, glnxa64, win64) and Octave (aarch64-..., x86_64-...) into canonical labels.
| Architecture | GCC/Clang Flags | MSVC Flags |
|---|---|---|
| arm64 (Apple Silicon) | NEON intrinsics (implicit on Clang, explicit -mcpu=apple-m3 on GCC) |
/O2 /fp:fast (NEON by default) |
| x86_64 | -O3 -mavx2 -mfma -ftree-vectorize -ffast-math |
/O2 /arch:AVX2 /fp:fast |
| x86_64 (SSE2 fallback) | -O3 -msse2 -ftree-vectorize -ffast-math |
/O2 /arch:SSE2 /fp:fast |
| unknown | -O3 -ffast-math |
/O2 /fp:fast |
On x86_64, if AVX2 compilation fails (e.g., on older hardware), the function automatically retries with SSE2 flags.
| Runtime | Compiler | Rationale |
|---|---|---|
| GNU Octave | Real GCC (searched via find_gcc) |
Superior auto-vectorization; falls back to system default |
| MATLAB (macOS/Linux) | Xcode Clang (MATLAB default) | MATLAB passes Clang-specific linker flags that GCC may reject |
| MATLAB (Windows) | MSVC (MATLAB default) | Standard MATLAB Windows compiler |
After compilation, shared MEX files needed by the SensorThreshold library are automatically copied into ../SensorThreshold/private/.
Project path setup script. Run once per MATLAB/Octave session, or add a call to your startup.m for automatic initialization.
cd FastPlot
setup;| Directory | Description |
|---|---|
libs/FastPlot |
Core plotting library |
libs/SensorThreshold |
Sensor and threshold system |
libs/EventDetection |
Event detection library |
libs/Dashboard |
Dashboard engine and widgets |
libs/WebBridge |
TCP server for web-based visualization |
- API Reference: FastPlot -- Core plotting class
- API Reference: Dashboard -- Dashboard and dock layout
- API Reference: Sensors -- Sensor threshold system
- MEX Acceleration -- Detailed MEX documentation
- Installation -- Setup and compilation
FastPlot Wiki
API Reference
Guides
Use Cases
Internals
Resources