%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   정해져서 아는 벡터길이
r1=0.78;
r2=1.797;
r3=1.4294;
r4=1;
r5=2.48;
r8=2;



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Guess

theta2=270;
theta3=15;
theta8=30;
theta9=90;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  정해져서 아는 벡터의 각각도값


theta1=0;        ;
theta4=270;
theta5=180;

n=1;
t=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  input

for theta1= 0: 10 : 100


while t~=0


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Scalar equations

f_freudenstein=[r1*cosd(theta1)+r2*cosd(theta2)-r3*cosd(theta3)-r4*cosd(theta4) ;
                r1*sind(theta1)+r2*sind(theta2)-r3*sind(theta3)-r4*sind(theta4) ;
    r5*cosd(theta5)+r4*cosd(theta4)+r3*cosd(theta3)+r8*cosd(theta8)+r9*cosd(theta9) ;
                r5*sind(theta5)+r4*sind(theta4)+r3*sind(theta3)+r8*sind(theta8)+r9*sind(theta9);
               
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Jacobian matrix

f_jacobian=[-r2*sind(theta2) r3*sind(theta3) 0 0 ;
            r2*cosd(theta2) -r3*cos(theta3) 0 0 ;
   0 0 -r8*sind(theta8) -r9*sind(theta9) ;
   0 0 r8*cosd(theta8) r9*sind(theta9) ];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Newton-Rapshon's Method - error

f_newton_rapshon_error=inv(f_jacobian)*(-f_freudenstein);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Newton-Rapshon's Method - root
theta2new=theta2+f_newton_rapshon_error(1);
theta3new=theta3+f_newton_rapshon_error(2);
theta8new=theta8+f_newton_rapshon_error(3);
r9new=r9+f_newton_rapshon_error(4);

theta2=theta2new;
theta3=theta3new;
theta8=theta8new;
r9=r9new;
theta2new=0;
theta3new=0;
theta8new=0;
r9new=0;

%%%%%%%%%%%%%%%%%%%set error range
if ((f_newton_rapshon_error(1,1)<10^(-5) & f_newton_rapshon_error(1,1)>-10^(-5))...
  & (f_newton_rapshon_error(2,1)<10^(-5) & f_newton_rapshon_error(2,1)>-10^(-5))...
  & (f_newton_rapshon_error(3,1)<10^(-5) & f_newton_rapshon_error(3,1)>-10^(-5))...
  & (f_newton_rapshon_error(4,1)<10^(-5) & f_newton_rapshon_error(4,1)>-10^(-5)));
 
 
  t=0 ;
  else
  t=1 ;
  end
  end
 
t=1;
n=n+1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Drawing graph
ox=0; oy=0;
Ax=ox+r1*cosd(theta1);   Ay=oy+r1*sind(theta1) ;
Bx=Ax+r2*cosd(theta2);   By=Ay+r2*sind(theta2) ;
Cx=Bx+r3*cosd(theta3);   Cy=By+r3*sind(theta3) ;
Dx=Cx+r4*cosd(theta4);   Dy=Cy+r4*sind(theta4) ;
Ex=Dx+r5*cosd(theta5);   Ey=Dy+r5*sind(theta5) ;
Fx=Ex+r8*cosd(theta8);   Fy=Ey+r8*sind(theta8) ;
Gx=Fx+r9*cosd(theta9);   Gy=Fy+r9*cosd(theta9) ;

L1x=[ox Ax] ; L1y=[oy Ay] ;
L2x=[Ax Bx] ; L2y=[Ay By] ;
L3x=[Bx Cx] ; L3y=[By Cy] ;
L4x=[Cx Dx] ; L4y=[Cy Dy] ;
L5x=[Dx Ex] ; L5y=[Dy Ey] ;
L6x=[Ex Fx] ; L6y=[Ey Fy];
L7x=[Fx Gx] ; L7y=[Fy Gy];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set(gca , 'visible' , 'on');
plot(L1x, L1y, L2x, L2y, L3x, L3y, L4x, L4y, L5x, L5y, L6x, L6y, L7x, L7y);
hold on
grid on
drawnow;
end







    
    








이거 어찌합니까


도와쥬십쇼