LogoLogo
HomeAPI & SDKsProjectsForumStudio
  • Getting started
    • For beginners
    • For ML practitioners
    • For embedded engineers
  • Frequently asked questions (FAQ)
  • Tutorials
    • End-to-end tutorials
      • Computer vision
        • Image classification
        • Object detection
          • Object detection with bounding boxes
          • Detect objects with centroid (FOMO)
        • Visual anomaly detection
        • Visual regression
      • Audio
        • Sound recognition
        • Keyword spotting
      • Time-series
        • Motion recognition + anomaly detection
        • Regression + anomaly detection
        • HR/HRV
        • Environmental (Sensor fusion)
    • Data
      • Data ingestion
        • Collecting image data from the Studio
        • Collecting image data with your mobile phone
        • Collecting image data with the OpenMV Cam H7 Plus
        • Using the Edge Impulse Python SDK to upload and download data
        • Trigger connected board data sampling
        • Ingest multi-labeled data using the API
      • Synthetic data
        • Generate audio datasets using Eleven Labs
        • Generate image datasets using Dall-E
        • Generate keyword spotting datasets using Google TTS
        • Generate physics simulation datasets using PyBullet
        • Generate timeseries data with MATLAB
      • Labeling
        • Label audio data using your existing models
        • Label image data using GPT-4o
      • Edge Impulse Datasets
    • Feature extraction
      • Building custom processing blocks
      • Sensor fusion using embeddings
    • Machine learning
      • Classification with multiple 2D input features
      • Visualize neural networks decisions with Grad-CAM
      • Sensor fusion using embeddings
      • FOMO self-attention
    • Inferencing & post-processing
      • Count objects using FOMO
      • Continuous audio sampling
      • Multi-impulse (C++)
      • Multi-impulse (Python)
    • Lifecycle management
      • CI/CD with GitHub Actions
      • Data aquisition from S3 object store - Golioth on AI
      • OTA model updates
        • with Arduino IDE (for ESP32)
        • with Arduino IoT Cloud
        • with Blues Wireless
        • with Docker on Allxon
        • with Docker on Balena
        • with Docker on NVIDIA Jetson
        • with Espressif IDF
        • with Nordic Thingy53 and the Edge Impulse app
        • with Particle Workbench
        • with Zephyr on Golioth
    • API examples
      • Customize the EON Tuner
      • Ingest multi-labeled data using the API
      • Python API bindings example
      • Running jobs using the API
      • Trigger connected board data sampling
    • Python SDK examples
      • Using the Edge Impulse Python SDK to run EON Tuner
      • Using the Edge Impulse Python SDK to upload and download data
      • Using the Edge Impulse Python SDK with Hugging Face
      • Using the Edge Impulse Python SDK with SageMaker Studio
      • Using the Edge Impulse Python SDK with TensorFlow and Keras
      • Using the Edge Impulse Python SDK with Weights & Biases
    • Expert network projects
  • Edge Impulse Studio
    • Organization hub
      • Users
      • Data campaigns
      • Data
        • Cloud data storage
      • Data pipelines
      • Data transformation
        • Transformation blocks
      • Upload portals
      • Custom blocks
        • Custom AI labeling blocks
        • Custom deployment blocks
        • Custom learning blocks
        • Custom processing blocks
        • Custom synthetic data blocks
        • Custom transformation blocks
      • Health reference design
        • Synchronizing clinical data with a bucket
        • Validating clinical data
        • Querying clinical data
        • Transforming clinical data
    • Project dashboard
      • Select AI hardware
    • Devices
    • Data acquisition
      • Uploader
      • Data explorer
      • Data sources
      • Synthetic data
      • Labeling queue
      • AI labeling
      • CSV Wizard (time-series)
      • Multi-label (time-series)
      • Tabular data (pre-processed & non-time-series)
      • Metadata
      • Auto-labeler | deprecated
    • Impulses
    • EON Tuner
      • Search space
    • Processing blocks
      • Audio MFCC
      • Audio MFE
      • Audio Syntiant
      • Flatten
      • HR/HRV features
      • Image
      • IMU Syntiant
      • Raw data
      • Spectral features
      • Spectrogram
      • Custom processing blocks
      • Feature explorer
    • Learning blocks
      • Anomaly detection (GMM)
      • Anomaly detection (K-means)
      • Classification
      • Classical ML
      • Object detection
        • MobileNetV2 SSD FPN
        • FOMO: Object detection for constrained devices
      • Object tracking
      • Regression
      • Transfer learning (images)
      • Transfer learning (keyword spotting)
      • Visual anomaly detection (FOMO-AD)
      • Custom learning blocks
      • Expert mode
      • NVIDIA TAO | deprecated
    • Retrain model
    • Live classification
    • Model testing
    • Performance calibration
    • Deployment
      • EON Compiler
      • Custom deployment blocks
    • Versioning
    • Bring your own model (BYOM)
    • File specifications
      • deployment-metadata.json
      • ei-metadata.json
      • ids.json
      • parameters.json
      • sample_id_details.json
      • train_input.json
  • Tools
    • API and SDK references
    • Edge Impulse CLI
      • Installation
      • Serial daemon
      • Uploader
      • Data forwarder
      • Impulse runner
      • Blocks
      • Himax flash tool
    • Edge Impulse for Linux
      • Linux Node.js SDK
      • Linux Go SDK
      • Linux C++ SDK
      • Linux Python SDK
      • Flex delegates
      • Rust Library
    • Rust Library
    • Edge Impulse Python SDK
  • Run inference
    • C++ library
      • As a generic C++ library
      • On Android
      • On your desktop computer
      • On your Alif Ensemble Series Device
      • On your Espressif ESP-EYE (ESP32) development board
      • On your Himax WE-I Plus
      • On your Raspberry Pi Pico (RP2040) development board
      • On your SiLabs Thunderboard Sense 2
      • On your Spresense by Sony development board
      • On your Syntiant TinyML Board
      • On your TI LaunchPad using GCC and the SimpleLink SDK
      • On your Zephyr-based Nordic Semiconductor development board
    • Arm Keil MDK CMSIS-PACK
    • Arduino library
      • Arduino IDE 1.18
    • Cube.MX CMSIS-PACK
    • Docker container
    • DRP-AI library
      • DRP-AI on your Renesas development board
      • DRP-AI TVM i8 on Renesas RZ/V2H
    • IAR library
    • Linux EIM executable
    • OpenMV
    • Particle library
    • Qualcomm IM SDK GStreamer
    • WebAssembly
      • Through WebAssembly (Node.js)
      • Through WebAssembly (browser)
    • Edge Impulse firmwares
    • Hardware specific tutorials
      • Image classification - Sony Spresense
      • Audio event detection with Particle boards
      • Motion recognition - Particle - Photon 2 & Boron
      • Motion recognition - RASynBoard
      • Motion recognition - Syntiant
      • Object detection - SiLabs xG24 Dev Kit
      • Sound recognition - TI LaunchXL
      • Keyword spotting - TI LaunchXL
      • Keyword spotting - Syntiant - RC Commands
      • Running NVIDIA TAO models on the Renesas RA8D1
      • Two cameras, two models - running multiple object detection models on the RZ/V2L
  • Edge AI Hardware
    • Overview
    • Production-ready
      • Advantech ICAM-540
      • Seeed SenseCAP A1101
      • Industry reference design - BrickML
    • MCU
      • Ambiq Apollo4 family of SoCs
      • Ambiq Apollo510
      • Arducam Pico4ML TinyML Dev Kit
      • Arduino Nano 33 BLE Sense
      • Arduino Nicla Sense ME
      • Arduino Nicla Vision
      • Arduino Portenta H7
      • Blues Wireless Swan
      • Espressif ESP-EYE
      • Himax WE-I Plus
      • Infineon CY8CKIT-062-BLE Pioneer Kit
      • Infineon CY8CKIT-062S2 Pioneer Kit
      • Nordic Semi nRF52840 DK
      • Nordic Semi nRF5340 DK
      • Nordic Semi nRF9160 DK
      • Nordic Semi nRF9161 DK
      • Nordic Semi nRF9151 DK
      • Nordic Semi nRF7002 DK
      • Nordic Semi Thingy:53
      • Nordic Semi Thingy:91
      • Open MV Cam H7 Plus
      • Particle Photon 2
      • Particle Boron
      • RAKwireless WisBlock
      • Raspberry Pi RP2040
      • Renesas CK-RA6M5 Cloud Kit
      • Renesas EK-RA8D1
      • Seeed Wio Terminal
      • Seeed XIAO nRF52840 Sense
      • Seeed XIAO ESP32 S3 Sense
      • SiLabs Thunderboard Sense 2
      • Sony's Spresense
      • ST B-L475E-IOT01A
      • TI CC1352P Launchpad
    • MCU + AI accelerators
      • Alif Ensemble
      • Arduino Nicla Voice
      • Avnet RASynBoard
      • Seeed Grove - Vision AI Module
      • Seeed Grove Vision AI Module V2 (WiseEye2)
      • Himax WiseEye2 Module and ISM Devboard
      • SiLabs xG24 Dev Kit
      • STMicroelectronics STM32N6570-DK
      • Synaptics Katana EVK
      • Syntiant Tiny ML Board
    • CPU
      • macOS
      • Linux x86_64
      • Raspberry Pi 4
      • Raspberry Pi 5
      • Texas Instruments SK-AM62
      • Microchip SAMA7G54
      • Renesas RZ/G2L
    • CPU + AI accelerators
      • AVNET RZBoard V2L
      • BrainChip AKD1000
      • i.MX 8M Plus EVK
      • Digi ConnectCore 93 Development Kit
      • MemryX MX3
      • MistyWest MistySOM RZ/V2L
      • Qualcomm Dragonwing RB3 Gen 2 Dev Kit
      • Renesas RZ/V2L
      • Renesas RZ/V2H
      • IMDT RZ/V2H
      • Texas Instruments SK-TDA4VM
      • Texas Instruments SK-AM62A-LP
      • Texas Instruments SK-AM68A
      • Thundercomm Rubik Pi 3
    • GPU
      • Advantech ICAM-540
      • NVIDIA Jetson
      • Seeed reComputer Jetson
    • Mobile phone
    • Porting guide
  • Integrations
    • Arduino Machine Learning Tools
    • AWS IoT Greengrass
    • Embedded IDEs - Open-CMSIS
    • NVIDIA Omniverse
    • Scailable
    • Weights & Biases
  • Tips & Tricks
    • Combining impulses
    • Increasing model performance
    • Optimizing compute time
    • Inference performance metrics
  • Concepts
    • Glossary
    • Course: Edge AI Fundamentals
      • Introduction to edge AI
      • What is edge computing?
      • What is machine learning (ML)?
      • What is edge AI?
      • How to choose an edge AI device
      • Edge AI lifecycle
      • What is edge MLOps?
      • What is Edge Impulse?
      • Case study: Izoelektro smart grid monitoring
      • Test and certification
    • Data engineering
      • Audio feature extraction
      • Motion feature extraction
    • Machine learning
      • Data augmentation
      • Evaluation metrics
      • Neural networks
        • Layers
        • Activation functions
        • Loss functions
        • Optimizers
          • Learned optimizer (VeLO)
        • Epochs
    • What is embedded ML, anyway?
    • What is edge machine learning (edge ML)?
Powered by GitBook
On this page
  • Example: Generating continuous motion data (up-down snake wave and idle) in MATLAB
  • Prerequisites
  • Getting Started
  • Customizing parameters to simulate motion data
  • Script overview
  • Multi-axis acc_x, acc_y, acc_z example
  • Generating and Labeling Multiple Classes
  • Benefits of using MATLAB for time-series data generation
  • Importing synthetic motion data into Edge Impulse
  • Use the CSV Wizard to import your data into a project.
  • Next steps
  • Conclusion
  • Further reading

Was this helpful?

Export as PDF
  1. Tutorials
  2. Data
  3. Synthetic data

Generate timeseries data with MATLAB

PreviousGenerate physics simulation datasets using PyBulletNextLabeling

Last updated 6 days ago

Was this helpful?

MATLAB is a powerful tool for generating synthetic motion data for machine learning applications. With built-in functions such as the Signal Processing Toolbox and Image Processing Toolbox and capabilities, MATLAB makes it easy to simulate real-world sensor data, generate labelled datasets, and preprocess data for edge AI applications.

In this tutorial, you will learn how to:

  1. Define simulation parameters (sampling frequency, signal duration, random seed).

  2. Generate multiple motion classes (e.g., “idle,” “snake,” “up-down”).

  3. Add realistic noise and emulate sensor characteristics.

  4. Label data automatically in MATLAB.

  5. Save your signals to CSV.

  6. Import the labeled CSV into Edge Impulse.

Example: Generating continuous motion data (up-down snake wave and idle) in MATLAB

Below, we recreate a continuous motion sample project that could be used to test wearable sensors, monitor vibrations, or simulate small repetitive movements in an industrial setting.

You can also clone the public project dataset to follow along: MATLAB: Synthetic Data Generation - Continuous motion recognition.

MATLAB Online

You can run MATLAB entirely in the browser using MATLAB Online. This makes it easy to share your project, collaborate, or quickly try out scripts without installing anything locally.

Prerequisites

You will need:

  • A MATLAB license or MathWorks account to access MATLAB Online.

  • Our synthetic motion generation script see the public project description for the full script.

Getting Started

  1. Open MATLAB or go to MATLAB Online.

  2. Create a new Live Script (.mlx) or MATLAB script (.m).

  3. Copy-paste the synthetic motion generation code from the public project description for continuous motion data.

Customizing parameters to simulate motion data

There are several parameters to consider when generating synthetic motion data. You can customize:

  • Sampling Frequency (fs): Controls how frequently data is sampled (e.g., 62.5 Hz).

  • Total Duration (t_end): How long the simulated signal is (e.g., 15 minutes).

  • Types of Motion:

    • Up-Down Motion: Simple sinusoidal vertical oscillations.

    • Snake Motion: Horizontal oscillation with amplitude modulation.

    • Wave Motion: Circular or elliptical motion in the XY-plane.

  • Add realistic noise or drift to make the data look more authentic. Consider sensor-specific noise levels and random jitter.

In this basic example we generate a simple up-down motion, but you can extend this to include more complex motions or multiple classes of motion.

Script overview

Running the Script: Generates labeled time-series data (e.g., idle, snake, updown, wave).Save to CSV: The script automatically writes to motion_data.csv.Visualize: MATLAB’s plot and subplot functions help verify that the signals make sense.

Below is a minimal code snippet compare with your own script for advanced features:

% Clear workspace to start fresh
clear; clc;

% Sampling settings
fs = 62.5;
t_end = 15 * 60; 
t = 0:1/fs:t_end-1/fs; 

% Generate signals
jitter = 0.1 * randn(size(t));    % random noise
updown_z = 0.8 * sin(2*pi*0.5 * t) + jitter;  % up-down motion

% Combine or loop over motions
combined_data = [t' updown_z'];
csv_filename = 'motion_data.csv';
writematrix(combined_data, csv_filename);

disp(['Data saved as ', csv_filename]);

% Quick plot
figure;
plot(t, updown_z, 'LineWidth', 1.5);
xlabel('Time (s)');
ylabel('Amplitude');
title('Synthetic Up-Down Motion');

Multi-axis acc_x, acc_y, acc_z example

In many real applications, you have multiple axes (e.g., acc_x, acc_y, acc_z). You can extend the same logic for each axis:

rng(0); % For reproducibility
fs = 62.5;
t_end = 15; 
t = 0:1/fs:t_end-1/fs;

% Generate multiple axes
noise_x = 0.05*randn(size(t));
noise_y = 0.05*randn(size(t));
noise_z = 0.05*randn(size(t));

signal_x = sin(2*pi*1.0 * t) + noise_x;
signal_y = 0.5 * sin(2*pi*0.5 * t) + noise_y;
signal_z = 0.8 * sin(2*pi*0.2 * t) + noise_z;

combined_data_3axis = [t' signal_x' signal_y' signal_z'];

Generating and Labeling Multiple Classes

If you want to generate multiple classes like idle, snake, updown, wave you can segment your time vector and assign labels programmatically.

Here’s a minimal example:

% Clear workspace
clear; clc; rng(0); % set random seed

% Sampling settings
fs = 62.5;
t_end = 60; % 1 minute total for example
t = 0:1/fs:t_end-1/fs;

% Pre-allocate signal arrays
motion_signal = zeros(size(t));
labels = strings(size(t)); % label each sample

% Example: define time ranges for each motion
idle_duration = 10;      % first 10s idle
snake_duration = 20;     % next 20s snake
updown_duration = 30;    % last 30s up-down

% Generate Idle
idle_idx = t <= idle_duration;
motion_signal(idle_idx) = 0 + 0.05*randn(1, sum(idle_idx)); 
labels(idle_idx) = "idle";

% Generate Snake motion
snake_idx = t > idle_duration & t <= (idle_duration + snake_duration);
snake_t = t(snake_idx) - idle_duration;
motion_signal(snake_idx) = 0.3 * sin(2*pi*0.8 * snake_t) + 0.05*randn(size(snake_t));
labels(snake_idx) = "snake";

% Generate Up-Down motion
updown_idx = t > (idle_duration + snake_duration);
updown_t = t(updown_idx) - (idle_duration + snake_duration);
motion_signal(updown_idx) = 0.8 * sin(2*pi*0.5 * updown_t) + 0.1*randn(size(updown_t));
labels(updown_idx) = "updown";

% Combine data and labels into one matrix
combined_data = [t' motion_signal'];
csv_filename = 'motion_data.csv';

% Write numeric data
writematrix(combined_data, csv_filename);

% Write labels in a second file or append to CSV with e.g. "writetable" 
T = table(t', motion_signal', labels', 'VariableNames', {'time','motion','label'});
writetable(T, 'motion_data_labeled.csv');

disp(['Data saved as ', csv_filename, ' and motion_data_labeled.csv']);

% Quick plot
figure;
plot(t, motion_signal, 'LineWidth', 1.2);
xlabel('Time (s)');
ylabel('Amplitude');
title('Synthetic Multi-Class Motion');

In practice, you can repeat this process for each axis (e.g., x, y, z) and store all signals plus labels in a single table.

Benefits of using MATLAB for time-series data generation

  • Enhance Data Quality: Create reliable time-series signals that closely mimic real-world conditions.

  • Increase Dataset Diversity: Generate multiple classes of motion, from subtle vibrations to large, sinusoidal oscillations.

  • Save Time and Resources: No need to set up physical experiments to capture sensor data—scripted generation is repeatable and cost-effective.

  • Improve Model Accuracy: High-quality, diverse signals help close dataset gaps, reducing overfitting and improving real-world performance.

Importing synthetic motion data into Edge Impulse

Use the CSV Wizard to import your data into a project.

Now that you have your synthetic motion data, you can import it into your project using the CSV Wizard.

  1. Open the Edge Impulse Studio and navigate to the Data Acquisition tab.

  1. Click on the CSV Wizard.

  1. Upload the motion_data.csv file.

  1. Follow the steps to label and import the data.

  1. Once the data is imported, you can start training your model using the synthetic motion data.

  1. Configure the model settings and train the model using the synthetic motion data.

For more advanced motion data generation, consider adding sensor noise, drift, or more complex motion patterns.

Next steps

For a more advanced example, see the public project:Rolling Element Bearing Fault Diagnosis that uses MATLAB to generate synthetic vibration data for bearing fault detection, based on the MATLAB Rolling Element Bearing Fault Diagnosis example.

Conclusion

By leveraging MATLAB for synthetic data generation, you can rapidly prototype and iterate without the overhead of physical sensors or mechanical rigs. This approach helps fill in dataset gaps, improves model robustness, and speeds up development cycles. Please share your own experience with MATLAB and other uses or projects with us on our forum.

Further reading

  • Integrate Custom MATLAB DSP blocks in Edge Impulse for advanced preprocessing before training your models. Check out the MATLAB DSP custom processing block.

  • Bearing wear analysis: Public Project

Once you have your synthetic data, you can use it to train a model in Edge Impulse. Check out the Continuous motion recognition project for a complete example.

Public project Dataset - Studio updown
MATLAB Synthetic Motion Data
MATLAB Script
CSV - Step 1
CSV - Step 2
CSV - Step 3
CSV - Step 4
Public project Dataset - Studio wave
Create Impulse