Low Pass Filter Accelerometer Data

1 回表示 (過去 30 日間)
MATLABmet
MATLABmet 2017 年 9 月 9 日
コメント済み: Jose Marques 2017 年 9 月 9 日
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 件のコメント
Jose Marques
Jose Marques 2017 年 9 月 9 日
Can you fix the code layout? There is some setence that is not in code format

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by