Having trouble smoothing waveform data

So, my problem is as follows: I have an experimentally obtained data set that is sinusoidal in form, with varying frequencies and amplitudes.
My problem is that the waveform has mini-peaks, or jitter, throughout the wave, and I cannot figure out a way to eliminate them. I have tried matlab's cftool and also medfilt1 without luck; the problem is that this jitter is sort of embedded in the wave, which if necessary I can provide a sample of. Essentially, just picture a sin-shaped wave with little parabolic jitters spread throughout the waveform.
Does anyone have any suggestions how I can go about eliminating these?

Respuestas (2)

Image Analyst
Image Analyst el 22 de Mzo. de 2014
Use the Savitkzy-Golay filter with order 3 or 5. It will smooth it right out. Post your data if you want a demo.
As you know, the sine wave can be estimated as a Taylor series so with enough terms and the proper window size in the Savitzky-Golay filter you should be able to get a reasonable sine wave out. The SG filter does a fit to a polynomial in a sliding window, so sliding a 5th order or 3rd order polynomial over a sine wave would be fine.
% Set up parameters.
polynomialOrder = 5;
windowWidth = 9;
% Savitzky-Golay sliding polynomial filter
smoothY = sgolayfilt(y, polynomialOrder, windowWidth);

2 comentarios

Image Analyst
Image Analyst el 22 de Mzo. de 2014
Editada: Image Analyst el 22 de Mzo. de 2014
With your data:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 25;
folder = 'C:\Users\ag123\Documents';
fullFileName = fullfile(folder, 'temp_data1.mat');
s = load(fullFileName);
% Get thea noisy sine wave signal
y = s.temp_data1;
% Get the x data
x = 1 : length(y);
subplot(2,1,1);
plot(x, y, 'b-', 'LineWidth', 2);
grid on;
title('Noisy Signal', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Now smooth with a Savitzky-Golay sliding polynomial filter
windowWidth = 161
polynomialOrder = 5 % Try 3 or 5 or 7
smoothY = sgolayfilt(y, polynomialOrder, windowWidth);
subplot(2,1,2);
plot(x, smoothY, 'b-', 'LineWidth', 2);
grid on;
title('Smoothed Signal', 'FontSize', fontSize);

Iniciar sesión para comentar.

ag123
ag123 el 22 de Mzo. de 2014
Editada: ag123 el 22 de Mzo. de 2014

0 votos

Ok thank you very much Image Analyst, this looks very much like what I need!
Here is a subset of the data in question, so it seems to resemble the picture you provided
Edit: After trying it out, it seems that the mini-peaks are still there.

1 comentario

Somnath Kale
Somnath Kale el 28 de Nov. de 2020
Thanks !! Dear image analyst this very very helpful thanku very much

Iniciar sesión para comentar.

Preguntada:

el 22 de Mzo. de 2014

Comentada:

el 28 de Nov. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by