Question

I have a system as follows:

A*(B-C-D) - ( sqrt( (E-x)^2 + (F-y)^2 ) - sqrt( (G-x)^2 + (H-y)^2 ) = p

A*(I-J-K) - ( sqrt( (L-x)^2 + (M-y)^2 ) - sqrt( (N-x)^2 + (O-y)^2 ) = p

The values of the coefficients [A-O] are know, and I'm trying to estimate [x,y] (by minimizing the value of p). If necessary, I have a starting guess [x0,y0].

I'm not very well-versed in function handling in matlab. How can I program this (using a RLS solution - which made me think of lsqnonlin)? Should I be using lsqnonlin at all?

I'm using MATLAB 2010b. Thanks guys.

PS: Sometimes I use an extra equation (similar to these two), therefor making the system overdetermined. Will it still work?

Was it helpful?

Solution

Using lsqnonlin makes sense ;

Considering documentation notations (http://www.mathworks.fr/fr/help/optim/ug/lsqnonlin.html), the functions are the following :

f1 = sqrt( (E-x)^2 + (F-y)^2 ) + sqrt( (G-x)^2 + (H-y)^2 ) + p - A(B-C-D)
f2 = sqrt( (L-x)^2 + (M-y)^2 ) - sqrt( (N-x)^2 + (O-y)^2 ) + p - A(I-J-K)

Solver will minimize f1^2 + f2^2. Of course, you can add additional equations, but they will not be considered as hard constraints.

If you want your solution to enforce constraints, you should be able to do it with fsolve.

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top