Perform Spectral Analysis on Live Data
This example shows how to use the Analog Input block to acquire live signals from a data acquisition device into Simulink. The block uses a National Instruments(R) USB-6211 as the input device. The Simulink model use a spectrum estimator to output a power spectrum estimate of a time-domain input using Welch's method of averaged modified periodograms.
Note: This example requires MATLAB®, Simulink, Data Acquisition Toolbox and DSP System Toolbox™ to open and run the model.
Data Acquisition and Processing
The input signal is a real-time analog signal sampled at 10000 samples per second. The Analog Input block is configured to do asynchronous acquisiton, which buffers the data from the analog channels and streams the buffered data to Simulink. Each timestep, the Analog Input block outputs a chunk of 1024 samples. Each chunk of data is processed by a Spectrum Estimator to calculate the power spectrum. You can adjust the settings in the Spectrum Estimator such as different window functions.
In this example the captured signal contains three major frequency components: sine waves at 50Hz, 250Hz, and 500Hz. The time domain signal, frequency domain signal from Spectrum Analyzer, and the one-side power spectrum estimate by spectrum estimator are shown below.
Even though a National Instruments device was used for this example, this model can be easily updated to connect to other supported data acquisition devices. This provides you the flexibility to reuse the same Simulink model with different data acquisition hardware.