Derivative of the incoming sensor data for a duration of 200ms
1 次查看(过去 30 天)
显示 更早的评论
I need to find the derivative of accelerometer sensor data coming via the serial port in real time for a duration of 200ms.
I get 69 samples per second but the processing can delay and reduce the samples. Iam not able to figure out how do I calculate the derivative with the time. I could calculate the moving average but not the derivative. I cannot simply assume the time and go for code. I have used 11 accelerometer sensors.
Here is the code:
s = serial('COM5','BaudRate',115200);
fopen(s);
%display data
k=1;
for j=0:inf
for i=1:34
data(i)=str2double(fscanf(s));
display(data);
pause(0.01)
end
% detect a sync bit
B=data(1,1);
if B==1000
D(k,:)=data; k=k+1;
else
continue;
end
% for three point moving average
if k >=4
V=D(k-3:k-1,:);
mv(k-3,:)=sum(V)./3;
display(mv);
else
continue;
end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Counter and Timer Input and Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!