type factr.m
function x = factr(n)
if n<=1
x = 1;
return
end
x = n * factr(n-1);
end
type combina.m
function resultado = combina(n,i)
resultado = factr(n)/(factr(i)*factr(n-i));
end
type bernstein.m
function bn = bernstein(n,i,t)
bn = combina(n,i).*(t.^i).*(1-t).^(n-i);
end
t=0:0.01:1;
V=[1 2 4 4.6;1 3 -1 1.5];
plot(V(1,:),V(2,:),'-*'); hold on
v=size(V);
v=v(2);
l=size(t);
x=zeros(v,l(2));
y=zeros(v,l(2));
for i=1:v
x(i,:)=bernstein(v-1,i-1,t)*V(1,i);
y(i,:)=bernstein(v-1,i-1,t)*V(2,i);
end
a=sum(x);
b=sum(y);
plot(a,b,'Linewidth',2);grid on
title('Curva Bézier');xlabel('Eje x');ylabel('Eje y')
hold off