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.

[xc,indw]=calcentroid(fnvalue,guess)
function [xc,indw]=calcentroid(fnvalue,guess)

[wor,indw]=max(fnvalue);

temp=zeros(5,2);

for i=1:length(guess)
    if (i~=indw)
        temp=temp+guess{i};
    end
end

xc=temp./8;

Contact us at files@mathworks.com