% jacobian Jz

function Jz=jacobianJz(z,q);

global b1 beta1 b2 beta2 b3 beta3 b4 beta4 b5 beta5 b6 beta6 b7 beta7 b8 beta8 b9 beta9 delta alfa gama b10 b11 b12 b13 b14 b15 b16 b17 b18 beta10 beta11 beta12 beta13 beta14 beta15 beta16 beta17 beta18 beta19

beta4=q(1);
beta7=q(2);

b1=z(1);
b2=z(2);
beta3=z(3);
beta6=z(4);
 beta10=z(5);
    beta11=z(6);
    beta12=z(7);
    beta16=z(8);

    beta5=beta3-delta;
    beta13=beta12-pi/2;
    beta14=beta3-gama;
    beta15=beta10+alfa;
    beta19=beta4-pi;

Jz=[cos(beta1), cos(beta2), -b3*sin(beta3),                 0,0,0,0,0
    sin(beta1), sin(beta2),  b3*cos(beta3),                 0,0,0,0,0
    cos(beta1), cos(beta2), -b3*sin(beta3)-b5*sin(beta5),   -b6*sin(beta6),0,0,0,0
    sin(beta1), sin(beta2),  b3*cos(beta3)+b5*cos(beta5),    b6*cos(beta6),0,0,0,0
    0,0,b14*-sin(beta3-gama),0,b10*-sin(beta10),b11*-sin(beta11),b12*-sin(beta12)+b13*-sin(beta12-pi/2),0
    0,0,b14*cos(beta3-gama),0,b10*cos(beta10),b11*cos(beta11),b12*cos(beta12)+b13*cos(beta12-pi/2),0
    0,0,0,0,b15*-sin(beta10+alfa),0,0,b16*-sin(beta16)
    0,0,0,0,b15*cos(beta10+alfa),0,0,b16*cos(beta16)                                                                                ];
