Pivoting

posted Feb 23, 2015, 6:35 PM by Javad Taghia   [ updated Jul 2, 2015, 5:26 AM ]
Matlab code:
function R = pivot(M, r, c) % r and c are pivoting point 
[d, w] = size(M); % Get matrix dimensions
R = zeros(d, w); % Initialize to appropriate size
R(r,:) = M(r, :) / M(r,c); % Copy row r, normalizing M(r,c) to 1
for k = 1:d % For all matrix rows
if (k ~= r) % Other then r
R(k,:) = M(k,:) ... % Set them equal to the original matrix
- M(k,c) * R(r,:); % Minus a multiple of normalized row r, making R(k,c)=0
end
end
end

eg: A = [1 2 3; 2 3 4]; B = pivot(A, 1, 1); 

YouTube Video




Ċ
Javad Taghia,
Jul 2, 2015, 5:26 AM
Ċ
pivot.pdf
(117k)
Javad Taghia,
Feb 23, 2015, 6:36 PM
Comments