How to solve a non linear ovedetermined system of equations??

1 visualización (últimos 30 días)
Please help me how solve this, using fmincon fsolve etc I am tired of syntax errors
eq(k)=(sqrt(x1-x0)^2+(y1-y0)^2+(z1-z0)^2)==c*(t1-t0); Unknowns are x0 y0 z0 and t0, eqn(k) are 8. I am not exactly sure what tricks to unleash with the optimization algorithms in matlab. I have even tried to simplify the equation further to sqrt (a1^2+a2^2+a3^2+a4^2==c*(ti-t0)); hoping to simplify it and solve for a1 a2 a3 and a4, find the sqrt and hopefully give a good estimate for the unknowns at this point I am frustrated its not working. I have watched all the optimization videos,they make really look easy but it isnt, someone help please before I loose my mind, thanks.
  3 comentarios
Alphonce Owayo
Alphonce Owayo el 28 de Feb. de 2021
The equation is
Sqrt((X1-x0)^2 +(Y1-y0)^2+(Z1-z0)^2) = c*(ti-t0). The unknowns are x0 y0 z0 and t0. I got 8 of these equations, but as you can see I got only four unknowns. The reason for this is, if I use only 4 equations, the solutions are likely to be highily inaccurate. This is just the basic equation of finding distances between two objects based on arrival time differences. The challenge is that this is an overdetermined system of non linear equations. How do I employ the techniques in Matlab to overcome this?
Alphonce Owayo
Alphonce Owayo el 28 de Feb. de 2021
The equation is just of that one form 8 times ofcourse with varying values of X1 Y1 Z1 and ti. I hope it's clearer.

Iniciar sesión para comentar.

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 28 de Feb. de 2021
You can always try with regular minimization. Perhaps something like this:
function err = err_1(pars,x,y,z,y)
c = 3; % guess, perhaps close to some factor of 10 off?
x0 = pars(1);
y0 = pars(2);
z0 = pars(3);
t0 = pars(4);
err = sum(((sqrt(x-x0).^2 + (y-y0).^2 + (z-z0).^2) - c*(t-t0)).^2);
end
Then you'll have to make an initial guess - that should preferably be close to the solution, this might be more or less important depending on the function (I haven't thought about what would be the case for your...);
x0y0z0t0_0 = [1,2,3,4]; % you hopefully have a hunch..
x0y0z0t0 = fminsearch(@(pars) err_1(pars,x,y,z,y),x0y0z0t0_0)
You can also use lsqnonlin if fminsearch is too slow. But then you'll have to modify err_1 to return reiduals instead of the sum of the residuals squared.
HTH
  4 comentarios
Bjorn Gustavsson
Bjorn Gustavsson el 3 de Mzo. de 2021
My pleasure.
...and: Yeah, in my experience lsqnonlin is "typically" more efficient. Though I find it easier to start with writing an explicit sum-of-squared-residuals and minimize that using fminsearch it is often better to rephrase the problem to use lsqnonlin.
Alphonce Owayo
Alphonce Owayo el 4 de Mzo. de 2021
Sorry I misspelled ' lsqnonlin'Yeah you are right, and with lsqnonlin you can restrict the search so you pretty reasonable values.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surrogate Optimization en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by