Main Content

getcurve

Interactive creation of cubic spline curve

Syntax

[xy,spcv] = getcurve

Description

[xy,spcv] = getcurve displays a gridded window and asks you for input. As you click on points in the gridded window, the broken line connecting these points is displayed. To indicate that you are done, click outside the gridded window. Then a cubic spline curve, spcv, through the point sequence, xy, is computed (via cscvn) and drawn. The point sequence and, optionally, the spline curve are output.

If you want a closed curve, place the last point close to the initial point.

If you would like the curve to have a corner at some point, click on that point twice (or more times) in succession.

You can’t use getcurve over an existing figure, but you can use these functions to do the same thing: MATLAB® function ginput , and cscvn in Curve Fitting Toolbox™.

Examples

Draw a Spline Over an Image

You can’t use getcurve over an existing figure, but you can use these functions to do the same thing. The following example code allows you to click an existing image to draw a spline through the points.

Draw the default image.

image

The function ginput collects mouse click points until you press Enter.

[x, y] = ginput

Click on the axis to select points. Press Enter when you have finished selecting points.

Fit and plot a spline through the points using the cscvn function.

spcv = cscvn( [x, y].' )
hold on
fnplt( spcv )
hold off 

See Also