Derivative of the incoming sensor data for a duration of 200ms
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Counter and Timer Input and Output finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!