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

1 次查看(过去 30 天)
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 个评论
Alphonce Owayo
Alphonce Owayo 2021-2-28
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 2021-2-28
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.

请先登录,再进行评论。

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2021-2-28
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 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2021-3-3
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 2021-3-4
Sorry I misspelled ' lsqnonlin'Yeah you are right, and with lsqnonlin you can restrict the search so you pretty reasonable values.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by