hola y aqui les enseñare una forma aun mas sencilla de hacer una funcion en matlab
function p=pcd(L1,L2,th1,th2)
px=L1*cos(th1)+L2*cos(th1+th2);
py=L1*sin(th1)+L2*sin(th1+th2);
p=[px; py];
p=pcd(L1,L2,th1,th2);
plot(p(1,:),p(2,:))
th1=30*pi/180;
th2=60*pi/180;
p=pcd(L1,L2,th1,th2);
robotgraph(L1,th1,p);
end