function x = test(A, b)
Ab = [A b];
[row, col] = size(Ab);
for i = 1 : row-1
[val, index] = max(abs(Ab(i:row, i)));
index = index + i - 1;
if index ~= i
Ab([index, i], :) = Ab([i, index], :);
end
for j = i+1 : row
beta = Ab(j, i) / Ab(i, i);
Ab(j, :) = Ab(j, :) - Ab(i, :) * beta;
end
end
x = zeros(row, 1);
for i = row : -1 : 1
x(i) = ( Ab(i, col) - Ab(i, i+1:col-1) * x(i+1:col-1, 1) ) / Ab(i, i);
end
博良的BLOG
列高元高斯消去法
Time: 2017年10月25日 18:37Motto
笨蛋自以为聪明,聪明人才知道自己是笨蛋
Comments