Filter löschen
Filter löschen

How to solve a nonlinear least squares with 3 variables

6 Ansichten (letzte 30 Tage)
John Lee
John Lee am 19 Nov. 2021
Kommentiert: John Lee am 1 Dez. 2021
% I would like to find u=[ u(1); u(2); u(3)]; size(u)=3-by-1;
"rho" and "rho2" are also functions of "u" and all scalar values and defined as below.
rho=norm(s-u) % s is a known 3-by-1 vector; so rho is Euclidian distance between s and u, i.e. sqrt((s(1)-u(1))^2+(s(2)-u(2))^2+(s(3)-u(3))^2).
rho2=a'*(s-u)/norm(s-u); % a is a known 3-by-1 vector
Does anyone know how to minimize the functin below?
h-G*u-Q*rho-R*rho2 ; % h is 4-by-1 kown matrix; G is a 4-by-3 kown matrix; and Q, R all are 4-by-1 kown matrix;
Actually I wanated to solve h-G*u-Q*rho-R*rho2=0 but it is overdetermined. So the nonlinear least squares method can be applied to this problem.
Thanks,

Akzeptierte Antwort

Pratyush Roy
Pratyush Roy am 1 Dez. 2021
Hi John,
The lsqonlin can be used to solve non linear least squares problems numerically.
The following code snippet might be helpful:
u0 = rand([3,1]);
s = rand([3,1]);
a = randi(10,[3,1]);
h = rand([4,1]);
G = rand([4,3]);
Q = rand([4,1]);
R = rand([4,1]);
f1 = @(u)(h-G*u-Q*norm(s-u)+R*a'*(s-u)./norm(s-u));
x = lsqnonlin(f1,u0)
Hope this helps!

Weitere Antworten (0)

Kategorien

Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by