A)
type factr.m
function f=factr(n) if n==0 f=1; else f = n*factr(n-1); end end
B)
type combina.m
function c=combina(n,i) c=factr(n)/(factr(i)*factr(n-i)); end
%C) type bernstein.m
function b=bernstein(n,i,t) b=combina(n,i).*t.^i.*(1-t).^(n-i); end
D)
t = linspace(0,1,100); V=[1, 2, 4, 4.6; 1, 3, -1, 1.5]; plot(V(1,:),V(2,:),'-o'); n=size(V); n=n(2); s=size(t); x=zeros(n,s(2)); y=zeros(n,s(2)); for i=1:n x(i,:)=bernstein(n-1,i-1,t)*V(1,i); y(i,:)=bernstein(n-1,i-1,t)*V(2,i); end a=sum(x); b=sum(y); hold on plot(a,b,'Linewidth',2) hold off
