Cubic splines with jagged data

A cubic spline provides a good approximation to a smooth curve, and alternative versions are available for free download (see Daily Download 22: Splines and Curves, Update to AL-Spline-Matrix, and xlwSciPy 1.09 – update for xlwings 0.10 and Scipy 0.18.1), but if a curve has a sharp change of direction a single cubic spline will deviate significantly from the required values near the change.  An example of curves where this is a problem is a reinforced concrete moment-curvature diagram, which has sharp changes of slope at the cracking moment, and also at the reinforcement yield point.

To deal with curves of this sort, I have added an MSplineA user defined function (UDF) to the CSpline2 spreadsheet, which may be downloaded (including open-source code) from:

CSpline2.zip

This function allows a curve to be divided into any number of segments, each of which may be either linear or cubic splines.  Input and output details, and a typical example are shown in the screen shots below:

Required input ranges are the X and Y values of the input data, a list of spline segments, listing the last node number of each segment, the spline type to be applied (1 = linear or 3 = cubic), and end curve or slope details for cubic splines, and the X values where interpolation is required:

Output for this example is shown below:

Looking more closely at the region near the cracking moments it can be seen that the MSplineA function has given a good approximation to the input values, whereas a single cubic spline deviates significantly:

This entry was posted in Arrays, Beam Bending, Concrete, Curve fitting, Excel, Newton, UDFs, VBA and tagged , , , , , , . Bookmark the permalink.

2 Responses to Cubic splines with jagged data

  1. Bob Jordan says:

    Doug. I also had problems with splines like you mention and tried Akima’s method. It often looks more natural. Worth adding to your repertoir.
    Bob J.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s