Low Pass Filter Accelerometer Data
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Jose Marques
le 9 Sep 2017
Can you fix the code layout? There is some setence that is not in code format
Réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!