Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.40 KB | None | 0 0
  1. % Newton Raphson - Problem 4
  2.  
  3.  
  4. close;
  5. clear;
  6. clc;
  7.  
  8.  
  9. x = [0;1];  % initial conditions
  10.  
  11.  
  12. for n = 1:50 % n = # iterations
  13.    
  14.    
  15. f = [2*x(1)^2 + x(2)^2 - 8;
  16.    
  17.      x(1)^2 - x(2)^2 + x(1)*x(2) - 4];
  18.  
  19.  
  20. J = [4*x(1)        ,  2*x(2)
  21.      2*x(1) + x(2) , -2*x(2) + x(1)];
  22.  
  23.  
  24. x = x - inv(J)*f;
  25.  
  26. end
  27.  
  28.  
  29. fprintf('x1 =');
  30. disp(x(1,1)); % displays voltage
  31. fprintf('x2 =');
  32. disp(x(2,1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement