Confusing about applying weighted least square for constant fitting
Mostrar comentarios más antiguos
I'm now fitting a line with noise. My equation is to minimize
corresponding to equation
, then I have
and
with
data. I want to caculate the best y. The WSL gives
for the answer. But now my confusing is what is Y? Is this
, which means my code is
, then I have
and
data. I want to caculate the best y. The WSL gives (1) is the matrix with number 1. Is this right for me? or I should use other function such as fminsearch(I saw in the community, maybe it's still my missunderstanding)...Thanks
Respuesta aceptada
Más respuestas (1)
X = ones(N,1)
W = diag(w)
Y = y
where y is the (Nx1) column vector of the measurements and w is the (Nx1) column vector of weights.
The result of your formula is the coefficient a of the line y=a that best approximates the measurements.
5 comentarios
WeiHao Xu
el 19 de Jul. de 2021
Torsten
el 19 de Jul. de 2021
The result is a number since you do constant fitting (you want to fit your vector y to a horizontal line y = a).
It is this number a that you get from the formula.
WeiHao Xu
el 19 de Jul. de 2021
Torsten
el 19 de Jul. de 2021
Correct.
WeiHao Xu
el 19 de Jul. de 2021
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
