% LETTERV  Use natural cubic splines (ncspline.m) to plot a script letter
% "v", using points taken from a written letter on graph paper.

t = 0:1:10;         % 11 points
xy = [3.0 7.0;      % I found it easiest to enter coordinates of points
      4.0 7.9;      %     this way, as a list of (x y) pairs
      4.8 6.0;
      5.1 4.0;
      5.3 2.6;
      6.0 2.0;
      7.1 3.0;
      7.9 5.0;
      8.2 6.0;
      9.0 7.4;
      10.0 7.6];
x = xy(:,1)';  y = xy(:,2)';      % extract just x and y separately

tf = 0:0.01:10;     % fine grid for plotting (on t-vs-x and t-vs-y axes)
xf = ncspline(t,x,tf);   yf = ncspline(t,y,tf);

% t-versus-x and t-versus-y plots, using subplot:
figure(1)
subplot(2,1,1), plot(t,x,'o',tf,xf), grid on, xlabel t, ylabel x
title("parameterized curve in pieces")
subplot(2,1,2), plot(t,y,'o',tf,yf), grid on, xlabel t, ylabel y

% plot in x,y plane; parameter "t" is never mentioned!
figure(2), plot(x,y,'o',xf,yf)
axis equal, grid on, xlabel x, ylabel y, title("the letter v")
