% Bezier.m plots N points on the Bezier curve with control points in C function [X] = Bezier(C,N,p) n = length(C(1,:)); % number of control points a = 0:(1/(N-1)):1; % parameter values along the Bezier curve I = (0:(n-1))'*ones(1,N); % matrix of index values P = ones(n,1)*a; % matrix of probabilities A = binopdf(I,n-1,P); % weights for control points X = C*A; % points on the Bezier curve plot(X(1,:), X(2,:)); if p==1, hold on plot(C(1,:), C(2,:), '.'); end;