MATLAB: How to fit a polynomial with inequality constraints on the coefficients

MATLAB: How to fit a polynomial with inequality constraints on the coefficients

constraintscurve fitting

I am trying to fit some data to the functional form:
f(x)=a(1)*exp(a(2)*x)+a(3)*(x^2)+a(4)*x-a(1)
I want to:
  1. force a(1)*a(2)+a(4) to have a maximum value of 10
  2. force f(x) to be positive at all values of x>0
I was trying to use lsqcurvefit, but it seems the function does not allow inequality constraints.
x_data=[1.26400000000000
2.04000000000000
3.54400000000000
4.76000000000000
6.26000000000000
7.64400000000000
11.7720000000000
13.6880000000000
18.3680000000000
18.3680000000000]
y_data=[8.36003800000000
14.0006040000000
32.5919380000000
47.0971720000000
50.7733640000000
46.9911360000000
41.1428660000000
37.6193000000000
39.4918400000000
39.0617800000000]
Thanks!

Best Answer

  • I enclose a file of code that attempts to find a good solution. If you run it a few times you will get different solutions, probably including some with a residue in the 1E-12 range, which is pretty much numeric noise considering the calculations.
    I ran the minimization further through some code I wrote. To my surprise, I found a number of points where the numeric residue is exactly 0, indicating a perfect fit after all of the round-off issues. There are wide range of values that occurs for: a rectangular area in a(1) and a(2), and the extension in a(3) might possibly be quantized a bit. The only correlation that shows up is that a(3) and a(4) taken together form narrow-ish straight line instead of filling a volume.
    The attached .mat includes a variable Q5A that lists over 800 points where the residue was 0.
  • Add a Comment

    Your email address will not be published. Required fields are marked *