How to solve an overdetermined set of equations using non-linear lest squares in Matlab -



How to solve an overdetermined set of equations using non-linear lest squares in Matlab -

a11 = cos(x)*cos(y) (1) a12 = cos(x)*sin(y) (2) a13 = -sin(y) (3) a21 = sin(z)*sin(x)*cos(y) - cos(z)*sin(y) (4) a22 = sin(z)*sin(y)*sin(x) + cos(z)*cos(y) (5) a23 = cos(x)*sin(z) (6) a31 = cos(z)*sin(x)*cos(z) + sin(z)*sin(x) (7) a32 = cos(z)*sin(x)*sin(y) - sin(z)*cos(y) (8) a33 = cos(x)*cos(z) (9)

i have set of 9 equations , 3 unknowns. unknowns x, y , z. know values of a11, a12, a13 ....... a33. these values might have noise , hence have utilize optimization algorithm find best fit values of x,y, , z.

how solve above set of overdetermined equations in matlab?

i have been searching online , came across few functions notably one .

but i'm confused what's best way approach problem. little direction needed....

my favorite lsqcurvefit optimization toolbox.

from documentation see requires:

function handle (fun) starting values parameters (x0) additional non-fitted parameters (xdata) in case not exist data values (ydata)

options can set optimset can specify 1 of several tested algorithms. maximal number of iterations or minimal threshold on function tolerance or parameter value tolerance can set there.

if chance should not have optimization toolbox, can utilize fminsearch , minimize to the lowest degree squares sum((ydata-fun(x)).^2) directly.

and illustration of writing function fun (also see documentation) in case here , using code question be:

function r = fun(p, xdata) x = p(1); y = p(2); z = p(3); % code here a11 = cos(x)*cos(y) a12 = cos(x)*sin(y) a13 = -sin(y) a21 = sin(z)*sin(x)*cos(y) - cos(z)*sin(y) a22 = sin(z)*sin(y)*sin(x) + cos(z)*cos(y) a23 = cos(x)*sin(z) a31 = cos(z)*sin(x)*cos(z) + sin(z)*sin(x) a32 = cos(z)*sin(x)*sin(y) - sin(z)*cos(y) a33 = cos(x)*cos(z) % in 1 matrix r = [a11, a12, a13, a21, a22, a23, a31, a32, a33]; end

one sees there no real difference between scalar , vectorial valued function. matlab automatically computes difference info , sums on it.

matlab least-squares nonlinear-optimization

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -