# Produce piecewise monotonic function with 3 points and their slope with MATLAB

I'm trying to reproduce the shape of an airfoil's camber line using the leading edge angle, the trailing edge angle, the chord and the max camber value.

I cannot use a spline because it overshoots the "max camber".

I cannot use 'pchip', a piecewise cubic Hermitian interpolation because I can't clamp ends.

I cannot use 'csape' as well because it is a cubic spline interpolation (and therefore overshoots)

I'm playing around to generate a fifth order function, but I fear it is a futile endeavor.

-

If by "clamp" you mean "set endpoint derivatives", then yes, MATLAB's pchip() won't let you do that. You will have to write your own implementation of the Fritsch-Carlson scheme for computing the slopes $y_i^\prime$ corresponding to inner points $(x_i,y_i)$, though:
$$y_i^\prime = \begin{cases}3(h_{i-1}+h_i)\left(\frac{2h_i+h_{i-1}}{d_{i-1}}+\frac{h_i+2h_{i-1}}{d_i}\right)^{-1} &\text{ if }\mathrm{sign}(d_{i-1})=\mathrm{sign}(d_i)\\ 0&\text{ if }\mathrm{sign}(d_{i-1})\neq\mathrm{sign}(d_i)\end{cases}$$
where $h_i=x_{i+1}-x_i$ and $d_i=\dfrac{y_{i+1}-y_i}{h_i}$, and then use your own values of $y_1^\prime$ and $y_n^\prime$.
I suppose you could use pchip() except in the first and last intervals, and build an extension that performs cubic Hermite interpolation at the ends, using your specified derivatives at one end and the Fritsch-Carlson derivative estimates at the other. Entirely your call, of course. – J. M. Jan 31 '12 at 19:38