MATLAB: Fit data with dependent parameters

fit dependent

Hi,
There are two rows of data, x and y. I would like to fit y = f(x), where
f(x) = a*x^3 + b*x^2 + (2a+3b)*x,
i.e. parameters are not independent.
I tried to use the function "fittype", but it does not work (Licensing error: -101,147).
I would like to know if there is any other way to solve it.
Thank you!

Best Answer

Yours is a linear problem, however the easiest way to estimate the parameters is likely an unconstrained nonlinear solver, such as fminsearch:
x = ...;
y = ...;
objfcn = @(b,x) b(1).*x.^3 + b(2).*x.^2 + (2*b(1) + 3*b(2)).*x;
[B,resnorm] = fminsearch(@(b) norm(y - objfcn(b,x)), [1;1]);
xv = linspace(min(x), max(x));
figure
plot(x, y, 'pb')
hold on
plot(xv, objfcn(B,xv), '-r')
hold off
grid