MATLAB: Non linear data fit (weighted least square)

non linear data fitweighted least square

Hello, I would like to fit a data set (X,Y) with a non linear function y=f(x,a,b) where a and b are the paramters to be fitted.
In my case both X and Y have an uncertainty.
Is there a way to carry out a weighted least square with MATLAB?
Can the uncertainty on X be taken into account?
I spent nearly one hour looking around for a way to do that but I had no success.
Thank you,

Best Answer

check:
-lsqcurvefit
-lsqnonlin (both are in optimization toolbox though)
im not sure how you want to take account of the uncertainty in x, but you can also program any optimization yourself. basically you just have to write an objective function and plug that into:
-fminsearch
or if you have optimization toolbox:
-fminunc (unconstrained optimization)
-fmincon (constrained opt.)