how to smooth an imported signal in workspace?

1 view (last 30 days)
i have data of sensor readings that i imported to matlab's workspace as a matrix , and the signal is very noisy so i want to filter it with low pass filter , and save it as a new matrix in workspace, how do i do that ? help please . the data is recorded at 10Hz. i applied the following code but it gave me the exact results of the unfiltered signal. (the results picture is attached)
t = (1:436);
plot( t, baroz2_crop), axis tight;
ylabel('Height (m)');
xlabel('time');
title('Quadrotor height');
%
noise = 10;
coeff1 = ones(10, noise)/noise;
%
avg1baroz2_crop = filter(coeff1, 10, baroz2_crop);
plot(t, [baroz2_crop avg1baroz2_crop]);
legend('noise','10 seconds average (delayed)','location','best');
ylabel('height');
xlabel('time');
title('Quadrotor height');
%
figure
delta_baroz_crop = baroz2_crop - avg1baroz2_crop;
delta_baroz_crop = reshape(delta_baroz_crop, 10, 436).';
%
plot(1:436, mean(delta_baroz_crop)), axis tight;
title('Mean Quadrotor height ');
xlabel('time');
ylabel('height');

Answers (0)

Community Treasure Hunt

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

Start Hunting!