This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Remove High-Frequency Noise from Gyroscope Data

This example shows how to remove the high-frequency outliers from a streaming signal using the dsp.MedianFilter System object™.

Use the dsp.MatFileReader System object to read the gyroscope MAT file. The gyroscope MAT file contains 3 columns of data, with each column containing 7140 samples. The three columns represent the X-axis, Y-axis, and Z-axis data from the gyroscope motion sensor. Choose a frame size of 714 samples so that each column of the data contains 10 frames. The dsp.MedianFilter System object uses a window length of 10. Create a dsp.TimeScope object to view the filtered output.

reader = dsp.MatFileReader('SamplesPerFrame',714,'Filename','LSM9DS1gyroData73.mat',...
medFilt = dsp.MedianFilter(10);
scope = dsp.TimeScope('NumInputPorts',1,'SampleRate',119,'YLimits',[-300 300],...
    'ChannelNames',{'Input','Filtered Output'},'TimeSpan',60,'ShowLegend',true);

Filter the gyroscope data using the dsp.MedianFilter System object. View the filtered Z-axis data in the time scope.

for i = 1:10
    gyroData = reader();
    filteredData = medFilt(gyroData);

The original data contains several outliers. Zoom in on the data to confirm that the median filter removes all the outliers.

Related Topics

Was this topic helpful?