Part 2-- Vectorized function.
function out=f(theta)
L_1=2;
L_2=sqrt(2);
L_3=L_2;
p_1=sqrt(5);
p_2=p_1;
p_3=p_1;
x=1;
y=2;
x_1=4;
x_2=0;
y_2=4;
gamma=pi*(1/2);
A_2=L_3*cos(theta)-x_1;
B_2=L_3*sin(theta);
A_3=L_2*cos(theta+gamma)-x_2;
B_3=L_2*sin(theta+gamma)-y_2;
D=2*(A_2.*B_3-B_2.*A_3);
N_1=B_3.*(p_2.^2-p_1.^2-A_2.^2-B_2.^2)-B_2.*(p_3.^2-p_1.^2-A_3.^2-B_3.^2);
N_2=-1*A_3.*(p_2.^2-p_1.^2-A_2.^2-B_2.^2)+A_2.*(p_3.^2-p_1.^2-A_3.^2-B_3.^2);
out=N_1.^2+N_2.^2-p_1.^2*D.^2;
Not enough input arguments.
Error in f_2 (line 35)
A_2=L_3*cos(theta)-x_1;