georgekar
Electrical
- Mar 14, 2006
- 3
Hi all!
I have a nonlinear system of 11 algebraic equations with 6 unknowns.
The problem which i try to solve and from which this system is coming is the analyzing of some vectors (in 3d space) onto three refrence axes (x,y,z). I know the amplitude of the vectors and the roll, pitch, and yaw.
When I try to use the fsolve or lsqnonlin functions the method is converging in a solution which is not a root.
Any ideas what I have to do , which parameters I have to change and in what mannner? I tried different initial points for the method but it does not help.
Here is my code:
First I define this function which contains my system of equations:
//
function f = fun_X(in)
global PITCH
th=PITCH;
global YAW
psi=YAW;
global ROLL
fi=ROLL;
global ACC_X %-> is known constant.
% %Analyzing the new X axis acceleration on the three reference axes.
f(1) = cos(psi)/in(1) - cos(th)/in(2);
f(2) = cos(fi)/in(3) - sin(psi)/in(1);
f(3) = sin(fi)/in(3) - sin(th)/in(2);
f(4) = ACC_X - sqrt((cos(th)/in(2))^2 +(cos(fi)/in(3))^2 +(sin(fi)/in(3))^2);
f(5) = ACC_X - sqrt((cos(th)/in(2))^2 +(cos(fi)/in(3))^2 +(sin(th)/in(2))^2);
f(6) = ACC_X - sqrt((cos(th)/in(2))^2 +(sin(psi)/in(1))^2+(sin(fi)/in(3))^2);
f(7) = ACC_X - sqrt((cos(th)/in(2))^2 +(sin(psi)/in(1))^2+(sin(th)/in(2))^2);
f(8) = ACC_X - sqrt((cos(psi)/in(1))^2+(cos(fi)/in(3))^2 +(sin(fi)/in(3))^2);
f(9) = ACC_X - sqrt((cos(psi)/in(1))^2+(cos(fi)/in(3))^2 +(sin(th)/in(2))^2);
f(10)= ACC_X - sqrt((cos(psi)/in(1))^2+(sin(psi)/in(1))^2+(sin(fi)/in(3))^2);
f(11)= ACC_X - sqrt((cos(psi)/in(1))^2+(sin(psi)/in(1))^2+(sin(th)/in(2))^2);
//
and then I call the fsolve function
//
[sol, fval, eflag, out] = fsolve('fun_X',[0.01 4 6], opts)
//
..or the lsqnonlin function
//
in0 = [0.3 0.4 0.5]
[in,resnorm] = lsqnonlin(@fun_X,in0)
//
THANKS A LOT!
I have a nonlinear system of 11 algebraic equations with 6 unknowns.
The problem which i try to solve and from which this system is coming is the analyzing of some vectors (in 3d space) onto three refrence axes (x,y,z). I know the amplitude of the vectors and the roll, pitch, and yaw.
When I try to use the fsolve or lsqnonlin functions the method is converging in a solution which is not a root.
Any ideas what I have to do , which parameters I have to change and in what mannner? I tried different initial points for the method but it does not help.
Here is my code:
First I define this function which contains my system of equations:
//
function f = fun_X(in)
global PITCH
th=PITCH;
global YAW
psi=YAW;
global ROLL
fi=ROLL;
global ACC_X %-> is known constant.
% %Analyzing the new X axis acceleration on the three reference axes.
f(1) = cos(psi)/in(1) - cos(th)/in(2);
f(2) = cos(fi)/in(3) - sin(psi)/in(1);
f(3) = sin(fi)/in(3) - sin(th)/in(2);
f(4) = ACC_X - sqrt((cos(th)/in(2))^2 +(cos(fi)/in(3))^2 +(sin(fi)/in(3))^2);
f(5) = ACC_X - sqrt((cos(th)/in(2))^2 +(cos(fi)/in(3))^2 +(sin(th)/in(2))^2);
f(6) = ACC_X - sqrt((cos(th)/in(2))^2 +(sin(psi)/in(1))^2+(sin(fi)/in(3))^2);
f(7) = ACC_X - sqrt((cos(th)/in(2))^2 +(sin(psi)/in(1))^2+(sin(th)/in(2))^2);
f(8) = ACC_X - sqrt((cos(psi)/in(1))^2+(cos(fi)/in(3))^2 +(sin(fi)/in(3))^2);
f(9) = ACC_X - sqrt((cos(psi)/in(1))^2+(cos(fi)/in(3))^2 +(sin(th)/in(2))^2);
f(10)= ACC_X - sqrt((cos(psi)/in(1))^2+(sin(psi)/in(1))^2+(sin(fi)/in(3))^2);
f(11)= ACC_X - sqrt((cos(psi)/in(1))^2+(sin(psi)/in(1))^2+(sin(th)/in(2))^2);
//
and then I call the fsolve function
//
[sol, fval, eflag, out] = fsolve('fun_X',[0.01 4 6], opts)
//
..or the lsqnonlin function
//
in0 = [0.3 0.4 0.5]
[in,resnorm] = lsqnonlin(@fun_X,in0)
//
THANKS A LOT!