MATLAB: Can I pass 2 equations into nlinfit function

constant estimationMATLABnlinfit

Hello, I am using the nlinfit function to estimate parameters (constants) for an equation with my data. In fact I have 2 different equations that depend on the same constants. Is there a way for me to input 2 different functions and from the nlinfit function retrieve values for the constants that provide the best fit over the two equations? Hopefully my question makes sense.
For example:
equation 1: y1= A*B*x / (1 + B*x + C)
equation 2: y2=A*B*x / (1 + B*x + C)^2
My data is for y1 and y2 as functions of x

Best Answer

If I remember correctly, nlinfit cannot, however lsqcurvefit can:
This works:
x = 1:10;
y1 = rand(1,10);
y2 = rand(1,10);
objfcn = @(b,x) [b(1)*b(2).*x./(1 + b(2).*x + b(3)); b(1)*b(2).*x./(1 + b(2).*x + b(3)).^2];
B = lsqcurvefit(objfcn, rand(3,1), x, [y1;y2]);
Make appropriate changes to work with your data.
.