3

I want to fit and draw a curve that is constrained with the following boundary condition:

diff (yfit)<=0

where yfit is the polynomial fitted function to degree n.

The condition ensures that the slope of the polynomial to any degree of is non-positive for all x .

How can I apply the condition using the "polyfit" function or any other polynomial fitting function?

Løiten
  • 3,185
  • 4
  • 24
  • 36

1 Answers1

0

From my limited point of mathematical view, a polynomial function of degree 2 for example has by definition a reagion with positive and negative slope. One thing you can try is using absolute values: Build your own fitting (ie least square is easy = polyfit) and dont use polynomial Functions, but absolute functions thereof.

Least sqare: take 0 = d/da ( sum( func-point)^2 ) and this for each order.. Wikipedia and others provide in depth descriptions.

mike
  • 791
  • 11
  • 26