Subtraction of gravity from accerelometer data
10 views (last 30 days)
Show older comments
Hello,
I'm having some trouble subtracting the gravitation from my accelerometer data. I'm following the implementation from this site http://www.owen-lu.com/program-accel-grav , but Matlab gives me this error code
"Error using quatmultiply (line 36)
First input elements are not real."
even when I'm using
quatmultiply(quat2(i+1,:),conj(quat2(i,:))
The section in my coding is the following:
%%
e_1 = [1 0 0];
e_2 = [0 1 0];
e_3 = [0 0 1];
e_1rot = zeros(height(T),3);
e_2rot = zeros(height(T),3);
e_3rot = zeros(height(T),3);
i = 1;
while i < height(T)
%I also used quatmultiply(quat2(i+1,:),conj(quat2(i,:)), but there was the error message
e_1rot(i,:) = quat2(i+1,:)*conj(quat2(i,:))*e_1*quat2(i,:)*conj(quat2(i+1,:));
e_2rot(i,:) = quat2(i+1,:)*conj(quat2(i,:))*e_2*quat2(i,:)*conj(quat2(i+1,:));
e_3rot(i,:) = quat2(i+1,:)*(conjquat2(i,:))*e_3*quat2(i,:)*conj(quat2(i+1,:));
i = i + 1;
end
where quat2 is the pure quaternion (without the real part) and conj(quat2) is the conjugation. Could it be that the basis vectors should be 4 dimensional, just like the quaternion? How do I solve then my 3 dimensional gravity problem?
I hope you guys can help me, if needed, I'll post the whole code for better understanding.
4 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Antennas, Microphones, and Sonar Transducers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!