高斯消元法是matlab中基础中的基础
首先我们要理解高斯消元是什么
将一个n*n的矩阵通过相加减最终化成三角矩阵
那么不难得出
读懂了这些,我们就可以开始进入matlab的程序结构
首先著名笔者用的是MATLAB R2019b版本
在编辑器中输入
function [x] = MyGauss(A, b)
% This is the code for Gaussian Elimination without Pivoting.
% Input:
% A n by p coefficient matrix
% b n by 1 right-hand-side matrix
% Output:
% x p by 1 solution matrix
% Get size of input
[n, p] = size(A);
% Check for zero diagonal e