高斯消元法的matlab代码
时间: 2024-02-12 11:47:12 浏览: 10
高斯消元法(含matlab编程).doc
5星 · 资源好评率100%
Sure, here's a sample MATLAB code for Gaussian elimination method:
function [x] = gausselim(A, b)
[n, m] = size(A);
aug = [A b];
for i = 1:n-1
pivot = aug(i,i);
for j = i+1:n
factor = aug(j,i)/pivot;
aug(j,:) = aug(j,:) - factor * aug(i,:);
end
end
x = zeros(n,1);
for i = n:-1:1
x(i) = (aug(i,m+1) - aug(i,i+1:n)*x(i+1:n))/aug(i,i);
end
end
Hope this helps!
阅读全文