%% Plot a B-spline of Order 4
% This example shows how to create a B-spline of order 4 using the bspline function.
%% Create a Knot Sequence and Plot the B-spline
% This figure shows a B-spline of order 4 and the four cubic polynomials that composes it.
%
% To replicate this figure in MATLAB ®, first create a knot sequence. A knot sequence must be non-decreasing.

t = [0 1.5 2.3 4 5];

% As you have defined five knots, the B-spline will be of order 4.
% Then plot the B-spline with knot sequence t, as well as its polynomial pieces, by using the bspline function.

bspline(t)

% This B-spline consists of 4 polynomial pieces: the red, green, purple, and black curves in the plot, each of degree 3.
% The vertical lines mark the knots t that you have previously defined.
% The B-spline with knots t(i)≤····≤ t(i+k) is positive on the interval (t(i)..t(i+k)) and is zero outside that interval. It is piecewise-polynomial of order k with breaks at the sites t(i),...,t(i+k). These knots may coincide, and the precise multiplicity governs the smoothness with which the two polynomial pieces join there.
%
%% Plot Another B-spline in a New Subplot
% Create a second knot sequence.

t2=[2 3 4 5];

% Plot the B-spline with knot sequence t2 in the same figure but in a different subplot.

bspline(t,1)
bspline(t2 ,2)

% Copyright 2019 The MathWorks, Inc.