Problem solving AX=B with matrix inverse

5 views (last 30 days)
Natalie Kurgan
Natalie Kurgan on 11 Feb 2014
Edited: Natalie Kurgan on 11 Feb 2014
I'm using Givens rotation to transform accelerometer data, but when I plot the x direction transform, the data has a threshold that it doesn't pass over, like the data is reflecting back over the line instead of continuing on. When I use the command prompt to find the inverse of X to multiply it by B and write those numbers in for the transformation matrix instead of inv(X) or X\B, there is no threshold. It is difficult to explain, so I've included the code below. Does anyone know why this is happening, and how I can make it work in the script so that I can use different data without going to the command line every time?
Here is the code that gives the appropriate plot: (NOTE: cy,cx,and cz are 1x60000 vectors, making B and A 3x60000)
n=length(cx);
A3=zeros(3,n);
for i=1:n
X3=[1 0 0;0 cr(i) sr(i);0 -sr(i) cr(i)]; %matrix for roll: already transposed
Y3=[cp(i) 0 sp(i);0 1 0;-sp(i) 0 cp(i)]; %matrix for pitch: already transposed
% cr/sr and cp/sp are cos/sin of roll and pitch
C3=X3*Y3; % Givens rotation matrix
C3_inv = [ 0.982111208554857 -0.007886478165887 -0.188136592647620;0 0.999122559306088 - 0.041882114149749; 0.188301816324000 0.041132893744442 0.981249464214524];
% Obtained from command line: inv(Y)*in(X)
A3(:,i)=C3_inv*[cy(i);cx(i);-cz(i)]; % Desired Matrix
end
And here is (one of the many) code that doesn't work:
for i=1:n
X1=[1 0 0;0 cr(i) -sr(i);0 sr(i) cr(i)]; %matrix for roll
Y1=[cp(i) 0 -sp(i);0 1 0;sp(i) 0 cp(i)]; %matrix for pitch
C1=X1'*Y1'; % rotation matrix
A3(:,i)=inv(C1)*[cy(i);cx(i);-cz(i)];
end
If I include any inverse calculation in the script, I will get a plot with a cutoff line. Any help is much appreciated.

Answers (0)

Categories

Find more on 3-D Scene Control 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!