Low Pass Filter Accelerometer Data
조회 수: 1 (최근 30일)
이전 댓글 표시
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
2017년 9월 9일
Can you fix the code layout? There is some setence that is not in code format
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!