Low Pass Filter Accelerometer Data

1 visualizzazione (ultimi 30 giorni)
MATLABmet
MATLABmet il 9 Set 2017
Commentato: Jose Marques il 9 Set 2017
Hi All,
attached it my code for gathering xyz accelerometer data from a serial stream. The code works well, plotting x,y,z data along with the vector sum of all three plots. However, I would like to add a simple low pass filter to smooth the data out a bit, which is causing me some difficulties,
cut_off=1e-3/delay/2;
order=16;
h=fir1(order,cut_off);
% start time tic;
loop = 0; while ishandle(graph1)
xyz = fscanf(s, '%f %f %f')';
if (loop < 10)
loop = loop + 1;
continue;
elseif (loop == 10)
loop = 0;
end
if(~isempty(xyz))
index = index + 1;
time(index) = toc;
if (numel(xyz) < 3)
continue;
else
x(index) = ((xyz(1, 1))+23)/258;
y(index) = ((xyz(1, 2))+8)/260;
z(index) = ((xyz(1, 3))+26)/253;
vs(index) = sqrt((((xyz(1, 1))+26)/253)^2+(((xyz(1, 2))+26)/253)^2+(((xyz(1, 3))+26)/253)^2);
%vsf(index)=conv(vs(index),h);
end
end
end
fclose(s); end
I'm getting the following message 'In an assignment A(:) = B, the number of elements in A and B must be the same'
How do I go about implementing the LPF correctly ?
Thanks,
  1 Commento
Jose Marques
Jose Marques il 9 Set 2017
Can you fix the code layout? There is some setence that is not in code format

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by