[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help needed with fsolve problem
From: |
Terry Duell |
Subject: |
Help needed with fsolve problem |
Date: |
Thu, 18 Jul 2013 09:10:40 +1000 |
User-agent: |
Opera Mail/12.16 (Linux) |
Hello All,
I have run into some difficulties in solving a set of simultaneous
equations, using fsolve.
I have known (measured) accelerations from an array of accelerometers, and
know the geometry.
What I want to do is derive the variables, shown below in the example code
snippet.
I started with the approach shown in the example, coding the projections
of each r, which produces results. (note this example code may not have
correct maths)
=====start code======
% the variables
% x(1) = theta, pitch angle
% x(2) = theta-dot, pitch velocity
% x(3) = theta-dotdot, pitch acceleration
% x(4) = phi, roll angle
% x(5) = phi-dot, roll velocity
% x(6) = phi-dotdot, roll acceleration
%
% the solution based on setting local origin at accelerometer 0
% set up the function
fcn =@(x) [a0z-r1z*cos(x(1))*x(3)-r1z*sin(x(1))*x(2)*x(2)-a1z,
a0z+r2z*cos(x(1))*x(3)+r2z*sin(x(1))*x(2)*x(2)-a2z,
a0z+r3z*cos(x(4))*x(6)+r3z*sin(x(4))*x(5)*x(5)-a3z,
a0z+r4z*cos(x(4))*x(6)+r4z*sin(x(4))*x(5)*x(5)-a4z,
...etc...];
[x info]= fsolve(fcn, [0 0 0 0 0 0]);
=======end code=======
What I would like to do is apply a rotation matrix to derive the projected
distances, as per the following example, and use those projected distances
instead of manually coding each
=======start code======
rotx = [1,0,0;0,cos(theta),-sin(theta);0,sin(theta),cos(theta)];
roty = [cos(theta),0,sin(theta);0,1,0;-sin(theta),0,cos(theta)];
rotz = [cos(theta),-sin(theta),0;sin(theta),cos(theta),0;0,0,1];
r = [rx,ry,rz];
rrotx = rotx*r';
newrz = rrotx(3,:);
=======end code========
The problem I have is that I can't see how to incorporate the rotation
matrix steps into the set of simultaneous equations to pass to fsolve,
such that x(1) and x(4) end up in the solution.
I should add, just in case it isn't clear, all the x variables and the
a1z, a2z etc, are 1D arrays.
Any advice on this will be much appreciated.
Cheers,
--
Regards,
Terry Duell
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Help needed with fsolve problem,
Terry Duell <=