So you mean that you want to constrain a cubic polynomial regression such that the x^2 term is zero?

For this I would use fsolve if you have the optimization toolbox.

If you don't, there is always the Nelder-Mead algorithm implemented as the function fminsearch.

You'd go something like this:

constraint = [1,0,1,1];

polyFunc = @(p) polyval(p.*constraint,x);

objectiveFunc = @(p) (y - polyFunc(p)).^2;

p0 = [1, 0, 2, 3];

p = fminsearch( objectiveFunc, p0 );

Instead of using polyval you could always just write the polynomial formula verbatim. However, this way you get a result that is consistent with other polynomial functions.

Warning: Nelder-Mead can be a hairy beast. Read the documentation, play around, and find ways to tame it.

## Best Answer