MATLAB: Curve fitting with lsqcurvefit (2 curves simultaneously)

curve fittinglsqcurvefit

Hello.
I need to adjust a few parameters x1, x2, .., xn of two different functions f1 and f2 simultaneously to some experimental data. When using lsqcurvefit, I can only fit parameters of a single function. I've actually solved my problem by creating a function f = f1+f2 and adjusting the parameters so f fits the sum of the points obtained experimentally for each function. I think there might be a better way to do that, since my results aren't good yet. What would you suggest? I've also tried to use fminsearch to minimize the residual using the least squares method, but it didn't work.
Thanks in advance.

Best Answer

When using lsqcurvefit, I can only fit parameters of a single function.
Why? You do know that the output of F(x,xdata) can be vector/matrix valued, right? The only requirement from the documentation is
"ydata must be the same size as the vector (or matrix) F returned by fun."
Related Question