SHARE
TWEET

Untitled

a guest Oct 10th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. A = [
  2.     1 0 -1 0 0 0 0
  3.     -1 1 1 0 0 0 0
  4.     0 -1 2 -1 0 0 0
  5.     0 -1 0 2 0 1 0
  6.     0 -1 -1 0 2 1 1
  7.     0 0 1 -1 0 2 -1  
  8.     0 0 0 -1 1 -1 2
  9. ];
  10.  
  11. b = [0 0 0 0 0 20 0]';
  12.  
  13. prog = 1e-6;
  14. max_iter = 500;
  15. t0 = b;
  16. lambda_all = [];
  17. lambda = (norm(t0, inf)/max(abs(t0)));
  18.  
  19.  for i = 1:max_iter
  20.     t1 = A*t0;
  21.     lambda1 = (norm(t1, inf)/max(abs(t0)));
  22.     lambda_all = [lambda_all lambda1];
  23.     if(abs(lambda1-lambda) < prog)
  24.        i = max_iter;
  25.        tend = (t1 /(norm(t1,inf)))
  26.     end    
  27.     i = i+1;
  28.     lambda = lambda1;
  29.     t0 = t1
  30.  end
  31.  
  32. figure(1)
  33. plot(lambda_all)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top