1.代码
%%列主元消去法
function ECPE = Elimination_of_column_pivot_entries(M,b)
global n;
[n,n] = size(M);
B =[M,b];
R_A = rank(M);R_B = rank(B);
if R_A ~= R_B
disp('方程无解');
elseif (R_A == R_B)&&(R_A == n)
disp('此方程有唯一解');
for k = 1:n-1
B = Column_pivot_transformation(B,k);
B = Elimination_method(B,k);
end
X = Upper_trig_iterative_solution(B);
else
disp('方程有无穷多组解');
end
disp('解向量为:');
ECPE = X;
%%列主元变换
%%指定p列,找出列最大值,以此值为主元进行行变换
function CPT = Column_pivot_transformation(M,p)
[m,n] = size(M);
s = max(M(p:m,p));
[x,y] = find(M(p:m,p) == s);
H = x+p-1;
Ch1 = M(H