from Fitting NURBS to a given set of data points by Vikash Gupta
Given a set of six points a closed NURBS curve is used to approximately fit all the six data points.

evaluatefunction(P,A)
function [fnvalue] = evaluatefunction(P,A)
   

    [C(:,1),C(:,2)]=getbspline(P); %generating closed B-Spline
    [sqerror,indices]=getdistance(C,A);     %computing error or the objective 

fnvalue=sqerror;

Contact us at files@mathworks.com