Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear all
- close all
- eps = 0.0005;
- x = ones(3,1);
- %A = [3 2 1; 2 8 4; 1 4 5];
- A = [1 2 3; 2 4 1; 3 1 6];
- V = A * x; % Move to upper scope
- x_normalized = x;
- max_val = 1e99;
- max_val_old = 0;
- diff = 1e99;
- i = 0;
- while true,
- diff = abs(abs(max_val) - abs(max_val_old));
- if abs(diff) < eps,
- break
- end
- %disp('**************');
- %fprintf('*** %d ***\n', i);
- %disp('**************');
- old_v = V;
- V = A * x_normalized;
- max_val_old = max_val;
- max_val = max(V, [], 1) ;
- x_normalized = V / max_val;
- i = i+1;
- end
- disp('*** Task 1 ***');
- i
- eigen_value = max_val
- eigen_vector = V / max_val
- disp('*** Task 2 ***');
- V_1 = eigen_vector / sqrt(sum(eigen_vector, 1))
- V1_V1T = V_1 * (V_1')
- a_prim = A - eigen_value * V1_V1T
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement