Non linear Least square fitting

1 次查看(过去 30 天)
aditi
aditi 2014-11-1
I have a data set with three columns of X, Y and Y_error coordinates... I have to fit a equation
y = a[x^(-1/k) - 37^(-1/k)]
and find a and k along with the error associated with them. Also while fitting we have to consider the 3rd column also i.e the errors with Y coordinate.
So basically I have to do weighted non linear LS fitting and all this without using CFTOOL

回答(1 个)

Star Strider
Star Strider 2014-11-1
This is how I would do it:
% % b(1) = a, b(2) = k
y = @(b,x) b(1).*[x.^(-1./b(2)) - 37.^(-1./b(2))];
XYE = rand(10,3); % X, Y, Error Vectors Matrix — Create Data
X = XYE(:,1); % X Data
Y = XYE(:,2); % Y Data
W = XYE(:,3); % Weight Data
WLSCF = @(b) sum(W.*(Y - y(b,X)).^2); % Weighted Least Squares Cost Function
B = fminsearch(WLSCF, rand(2,1));
The error vector is apparently the weighting vector. My ‘XYE’ matrix has as its first column X, second column Y and third column E.
See 4.4.3.2. Weighted Least Squares for more information.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by