filtering the noise accelerator
Mostrar comentarios más antiguos
Hi All
i have 4 series results of accelerometer in excel. our test is about a metal ball that downfall from spesific height to soil. the accelerometer is set up on the ball.
now, our results have a noise. how i can filter the noise im matlab?
thank you.
1 comentario
William Rose
el 11 de Mzo. de 2021
Please provide a data file and your Matlab code to read the file and plot the data. This will make it easier for others to assist you.
Respuestas (1)
William Rose
el 11 de Mzo. de 2021
See code below. The code has three parts: 1. Read the data from an Excel file. 2. Filter the data. 3. Plot the raw and filtered data. You will have to choose a filter cutoff frequency that is appropriate for your data. I chose a 2nd order Butterworth lowpass filter because it is traditional. You could choose a different order or a different filter. I would not use a filter order higher than 6 with this technique, due to stability concerns. I chose to use filtfilt() because it has zero phase distortion. filtfilt() filters the data forwards and backwards. Because it filters the data twice, the attenuation is 6 dB at the cutoff frequency, instead of 3 dB. I have attached the Excel file used in the example code. I have also attached a screenshot of the figure prodced by the code.
%faroughCode.m
%Code for Farough Amini. 2021-03-10. W.C.Rose.
%Read the data from Excel file
%Replace the constants below with values for your file.
filename=['faroughData.xlsx'];
range='B95:E334';
x=xlsread(filename,range); %each column of array x is one series
[N,numSeries]=size(x); %N=number of rows; numSeries=number of series
fs=4000; %fs=sampling rate, in Hertz. Enter correct value for your data.
t=(0:N-1)/fs; %vector of time values
%Filter the data
fc=500; %filter cutoff frequency, in Hertz.
%Enter a value for fs that is appropriate for your data. fc must be < fs/2.
order=2; %filter order desired
[b,a]=butter(order,fc/(fs/2)); %coefficients for a 2nd order Butterworth lowpass filter
y=filtfilt(b,a,x); %Filter the data. Each column of y is one filtered series.
%I have used filtfilt() because it has zero phase distortion at all frequencies.
%filtfilt() filters the data in the forward direction and in the reverse direction.
%Plot the raw data and the filtered data
figure;
for i=1:numSeries
subplot(numSeries,1,i);
plot(t,x(:,i),'r.',t,y(:,i),'r-'); %plot raw and filtered data
titlestr=sprintf('Series %d',i);
title(titlestr); %title
ylabel('Force (N)'); %y-axis label
legend('Raw','Filtered'); %legend
if i==numSeries, xlabel('Time (s)'); end %x-axis label on bottom plot
end
Screenshot of the output:

A lowpass filter to reduce noise will attenuate the heights of sharp peaks and valleys. This is evident in this example, with the 500 Hz cutoff frequency which I have chosen: notice the difference between the raw and filtered signals at the peak + and - values. If you are estimating soil mechanical properties from deceleration of a penetrator, the estimates may be significantly affected by filtering. If the filter cutoff frequency is too low, the peaks will be attenuated, and the estimated mechanical properties may be incorrect.
Background information, in case you are interested:
The Series 1 data is vertical force from a steel force plate in a biomechanics laboratory, when a small steel ball was dropped on the plate from 1 meter. The ball bounced and was caught after the first impact. The sampling rate was 4 kHz. Therefore this data shows the impulse response of the force plate. For Series 2-4, I added Gaussian white noise to the Series 1 data, so that the data set would have 4 series, like your data. The standard deviation of the added noise was equal to 2, 5, and 10 times the standard deviation of the zero-force baseline in Series 1.
Categorías
Más información sobre Statistics and Linear Algebra en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!