Skip to content

Examples

github-actions[bot] edited this page Mar 22, 2026 · 16 revisions

Examples

FastPlot includes 80+ runnable examples demonstrating core features, dashboards, sensors, event detection, and stress tests. Each example is self-contained and works in both MATLAB and GNU Octave.

Quick Start

install;
cd examples

example_basic;          % Run a specific example
run_all_examples;       % Run all sequentially
demo_all;               % Interactive demo (keeps plots open)

Basic Plotting

Example Points Features
example_basic 10M Sine wave with upper/lower alarm and warning thresholds, setScale() for log axes, updateData() for in-place replacement
example_multi 5×1M Multiple lines with auto color cycling and shared thresholds, resetColorIndex()
example_100M 100M Stress test with 100 million points (~800 MB). Shows DeferDraw, ShowProgress options, ConsoleProgressBar for custom loops
example_nan_gaps 1M NaN dropout handling with seamless gap rendering
example_uneven_sampling Variable Event-driven variable-rate sampling (sparse + dense bursts)

Advanced Signals

Example Points Description
example_vibration 20M 50 kHz accelerometer with shaft frequency harmonics and bearing defect bursts. ISO 10816-style multi-level thresholds
example_ecg 5M 1 kHz ECG with QRS complexes, premature ventricular contractions (PVCs), baseline wander, and arrhythmia detection bands
example_lttb_vs_minmax 5M Side-by-side LTTB (shape-preserving) vs MinMax (peak-preserving) downsampling comparison with linked zoom

Visual Features & Styling

Example Description
example_alarm_bands Industrial 4-level HH/H/L/LL alarm thresholds with colored band regions and dashed/dotted line styles
example_visual_features 2×2 dashboard: addBand() shading, addShaded() confidence envelopes, addFill() area-under-curve, addMarker() annotations
example_themes All 6 built-in presets (default, dark, light, industrial, scientific, ocean), color palettes, dynamic theme switching with reapplyTheme()
example_toolbar FastSenseToolbar with data cursor, crosshair, grid/legend toggle, Y-axis autoscale, PNG export, violation marker visibility, metadata binding
example_datetime 50M-point temperature series with datenum X-axis. Auto-formatted tick labels adapt to zoom level (date+time → time → seconds)

Grid Layouts & Dashboards

Example Dimensions Description
example_dashboard 2×2 FastSenseGrid with dark theme, bands, shaded envelopes, filled areas, fill-under-curve markers
example_dashboard_9tile 3×3 9-tile industrial monitoring: temperature (bands), flow (thresholds), pressure (shaded), motor current (fill), vibration (fault markers), humidity (bands), RPM (LTTB), O₂ (NaN recovery), power spectrum (overlaid difference)
example_mixed_tiles 2×3 Mix FastSense time series with raw MATLAB axes (bar, scatter, histogram) using fig.tile() and fig.axes()
example_linked 3 subplots Pressure/Temperature/Vibration synchronized via LinkGroup — zoom one, all follow
example_multi_sensor_linked 4 channels Temperature/Pressure/Flow/Vibration with HH/H/L/LL thresholds per channel, state-dependent rules

FastSenseDock (Tabbed Dashboards)

Example Tabs Content Points
example_dock 5 Temperature, Power, Hydraulics, Electrical, Environment. Datetime X-axes, metadata annotations, bands/fills ~15M
example_dock_disk 5 Turbine, ChemProc, Compressor, PowerGen, Environment. Disk-backed (100M+), dynamic state-dependent thresholds ~100M
example_dock_many_tabs 20 Scrollable tab bar stress test (each tab: sine variant) 1K per tab

Sensors & Thresholds

Example Type Description
example_sensor_static Simple Basic Sensor with static upper/lower thresholds, violation detection, status queries
example_sensor_threshold Dynamic Pressure sensor with 3 machine states (idle/run/evacuate) → 3 different threshold sets. StateChannel + ThresholdRule
example_sensor_multi_state Advanced Two state channels (machine mode, zone) with compound AND conditions. getThresholdsAt() query
example_sensor_registry Catalog SensorRegistry singleton: list(), printTable(), get(), getMultiple(), register()/unregister(), interactive viewer()
example_sensor_dashboard Integrated 2×2 FastSenseGrid combining registry sensors with manual sensors, state-dependent thresholds, addStateChannel(), addThresholdRule(), resolve()
example_sensor_todisk Storage Sensor disk-backing: toDisk() / toMemory(), SQLite DataStore, multi-sensor dashboard with independent per-sensor storage
example_sensor_detail_basic Viewer SensorDetailPlot: navigator strip + detail pane with interactive zoom rectangle
example_sensor_detail Advanced SensorDetailPlot with thresholds and Event objects, state bands, dashboard embedding
example_sensor_detail_datetime Time-aware SensorDetailPlot with datenum X-axis and formatted clock labels
example_sensor_detail_dock Dashboard 4 tabs combining SensorDetailPlot (3 sensors) + plain FastSense, each with navigator

Event Detection & Live Monitoring

Example Sensors Features
example_event_detection_live 3 MockDataSource with random violations, EventDetector with debounce, EventViewer Gantt timeline + table, click-to-plot, console logging via eventLogger(), live FastSense dashboard
example_event_viewer_from_file 6 EventStore with atomic writes and backup rotation, EventViewer refresh (manual + auto), background file updates during viewing
example_live_pipeline 10 Complete LiveEventPipeline: data sources (MockDataSource, MatFileDataSource), IncrementalEventDetector, EventStore, NotificationRule matching, generateEventSnapshot, EventViewer auto-refresh

Data Storage

Example Size Description
example_disk_storage 50M FastSenseDataStore SQLite-backed chunking, 5 storage modes (auto, disk, memory, custom limit, DataStore API), range/slice queries, memory-only zoom simulation

DashboardEngine (Persistent, Multi-Widget)

Example Widgets Description
example_dashboard_engine FastSense + Number Sensor-bound widgets, dynamic thresholds via StateChannel, JSON save/load, programmatic widget management (setWidgetPosition, removeWidget)
example_dashboard_all_widgets 14 All widget types: FastSense, Number, Status, Gauge, Text, Table, RawAxes, Timeline, Heatmap, BarChart, Histogram, Scatter, Image, MultiStatus
example_dashboard_live 8 Live mode with 10 Hz periodic updates, timer-driven data ingestion, all widget types, mode cycling, alarm log
example_dashboard_groups Grouped GroupWidget (panel, collapsible, tabbed) organizing motor monitoring dashboard
example_dashboard_info 4 + Markdown Dashboard with InfoFile property, browser-rendered Markdown documentation, JSON persistence

New Widgets (Phase B)

Example Widget Types Description
example_widget_fastsense FastSenseWidget Sensor binding, inline XData/YData, state-dependent thresholds, custom axis labels
example_widget_number NumberWidget Sensor binding, callback, static value, trend indicators, format strings
example_widget_gauge GaugeWidget Four styles (arc, donut, bar, thermometer), sensor-derived ranges/colors, callback data
example_widget_status StatusWidget Sensor binding, callback, static status; color mapping
example_widget_table TableWidget Static arrays, callback, sensor-bound (last N readings)
example_widget_text TextWidget Alignment, font sizing, adaptive scaling
example_widget_rawaxes RawAxesWidget Four plot signatures, histogram/scatter/bar stats, distribution stems
example_widget_timeline EventTimelineWidget Event struct arrays, Event objects, EventStore, EventFcn callbacks, FilterSensors
example_widget_heatmap HeatmapWidget DataFcn 2D grids, correlation matrices, sensor reshape, colormaps
example_widget_barchart BarChartWidget Vertical/horizontal bars, stacking, production by shift, alarm counts
example_widget_histogram HistogramWidget Auto/custom bins, normal curve overlay, bimodal detection
example_widget_scatter ScatterWidget XY correlation, 3-sensor color-coding, marker size
example_widget_image ImageWidget Procedurally generated images, grayscale/RGB, scaling modes (fit/fill/stretch)
example_widget_multistatus MultiStatusWidget 8 sensors, dot/square icons, threshold-derived colors, grid layout

External Data Integration

Example Pattern Description
example_load_module_data Multi-sensor .mat ExternalSensorRegistry, loadModuleData() field matching, shared datenum axis
example_load_module_metadata State channels loadModuleMetadata() compresses dense state → sparse transitions, introspects ThresholdRule conditions, attaches StateChannels

Architecture & Performance

graph LR
    A["FastSense<br/>10K–100M pts<br/>binary search<br/>MinMax/LTTB"]
    B["FastSenseGrid<br/>tiled layout<br/>theme cascade"]
    C["FastSenseDock<br/>tabbed grid<br/>date/time axes"]
    D["DashboardEngine<br/>24-col grid<br/>persistent JSON<br/>live mode"]
    E["Sensor<br/>state channels<br/>thresholds"]
    F["EventDetection<br/>violations→events<br/>severity escalation"]
    G["WebBridge<br/>TCP/HTTP<br/>remote web UI"]
    
    A --> B
    A --> C
    A --> D
    E --> A
    E --> F
    F --> D
    D --> G
Loading

Benchmarks & Performance

Script Measurements Description
benchmark 10K–50M FastSense vs plot(): render, zoom, point reduction, GPU memory
benchmark_zoom Per-frame latency 100K–50M points, zoom levels 100%–0.1%, 95th percentile FPS
benchmark_features Overhead Bands, shading, fills, markers across 10K–10M points
benchmark_memory RAM savings In-memory vs disk storage, resolve() performance, segmented processing
benchmark_resolve Algorithm speedup Segment-based vs naive O(N×R) threshold detection, MEX acceleration
benchmark_resolve_stress Realistic scale 500M points, 5K state transitions, 4 rules with complex conditions
benchmark_datastore I/O efficiency .mat file vs SQLite, range queries, slice reads, 10K–500M points
profile_datastore Function bottlenecks DataStore creation, range queries, zoom cycles at 5M–50M scale

Running All Examples

% Sequential with 5s pauses between runs
run_all_examples

% Interactive demo (keeps all plots open for exploration)
demo_all

% Batch/headless (useful for CI/benchmarking)
demo_all('interactive', false)

See Also

Clone this wiki locally