Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.91 KB | None | 0 0
  1. % Newton Raphson - Problem 1
  2.  
  3.  
  4. close;
  5. clear;
  6. clc;
  7.  
  8.  
  9. P2 = 1.8  % P p.u.
  10. Q2 = 0.6  % Q p.u.
  11. Z= i*0.1; % impedance
  12.  
  13. Y = [1/Z , -1/Z ;
  14.      -1/Z , 1/Z]; % admittance matrix (2x2)
  15.  
  16. Gik = real(Y); % takes real component of Y matrix (ie Gik) into 2x2 matrix
  17. Bik = imag(Y); % take imaginary cmponents of Y matrix (ie Bik) into 2x2 matrix
  18.  
  19. x = [0;1];  % initial conditions
  20.  
  21.  
  22. for n = 1:50 % n = # iterations
  23.    
  24.    
  25. f = [Bik(2,1)*x(2)*sin(x(1)) + P2;
  26.    
  27.      -Bik(2,1)*x(2)*cos(x(1)) - Bik(2,2)*x(2)^2 + Q2];
  28.  
  29.  
  30. J = [Bik(2,1)*x(2)*cos(x(1)) , Bik(2,1)*sin(x(1));
  31.      Bik(2,1)*x(2)*sin(x(1)) , -Bik(2,1)*cos(x(1))-2*Bik(2,2)*x(2)];
  32.  
  33.  
  34. x = x - inv(J)*f;
  35.  
  36. end
  37.  
  38. k1 = x(1,1); % this is the angle in radians
  39. k2 = x(2,1); % this is the voltage (V2)
  40. k3 = k1*(180/pi); % radians to degree
  41.  
  42.  
  43. fprintf('V =');
  44. disp(x(2,1)); % displays voltage
  45. fprintf('theta =');
  46. disp(k3); % Displays angle (in degrees)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement