clc clear all Y=[8.98519-44.835953i -3.815629+19.078144i -5.169561+25.847809i 0; -3.815629+19.078144i 8.98519-44.835953i 0 -5.169561+25.847809i; -5.169561+25.847809i 0 8.193267-40.863838i -3.023705+15.118528i; 0 -5.169561+25.847809i -3.023705+15.118528i 8.193267-40.863838i]; G=real(Y); B=imag(Y); n=4; v=[1 1 1 1.02]; th=[0 0 0 0]; for i=1:n; for j=1:n jac(i,j)=v(i)*(G(i,j)*sin(th(i)-th(j))-B(i,j)*cos(th(i)th(j)))*v(j); jac(i+n,j)=-v(i)*(G(i,j)*cos(th(i)-th(j))+B(i,j)*sin(th(i)th(j)))*v(j); jac(i,j+n)=-jac(i+n,j); jac(i+n,j+n)=jac(i,j); end end for i=1:n Q(i,1)=sum(jac(i,1:n)); P(i,1)=-sum(jac(i+n,1:n)); end J11=jac(1:n,1:n); J12=jac(1:n,n+1:2*n); J21=jac(n+1:2*n,1:n); J22=jac(n+1:2*n,n+1:2*n); for j=1:n J11(j,j)=-Q(j,1)-B(j,j)*v(j)^2; J12(j,j)=P(j,1)+G(j,j)*v(j)^2; J21(j,j)=P(j,1)-G(j,j)*v(j)^2; J22(j,j)=Q(j,1)-B(j,j)*v(j)^2; end J=[J11 J12; J21 J22]; round (J,6)
ans
44.9260 -19.0781 -25.8478 -19.0781 45.4429 -25.8478 0
0
0
0
-5.1696
0
0
-5.2730
0
8.1328
-3.0842
-5.2730
-3.0842
8.6914
-26.3648 -3.8156 8.8818
41.2687 -15.4209 -5.1696
-26.3648 -15.4209 41.7857
-8.9852 3.8156
8.9852 -3.8156
5.1696
0
0
44.7460 -19.0781 -25.8478
3.8156
-9.0886
0
5.2730
-19.0781 44.2290
5.1696
0
-8.2537
3.0842
-25.8478
3.0842
-8.3571
0
0
5.2730
0
0
0 -26.3648
40.4590 -15.4209
-26.3648 -15.4209 43.2438