关于matlab高斯消去法,翻译下注释就可以了,在线等

一、高斯消去法的程序:
function [A,b]= Gauss(A,b);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%use Gaussian elimination method to change 'A' into upper triangular matrix
% Nov 26,2008
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[m,n]=size(A); %get the size of matrix 'A'

% column pivotal elimination method
for k=1:n-1
[v,u]=max(abs(A(k:n,k))); %select the maximum element into the kth
%column of matrix A(k:n,1:k)
u=u+k-1; %because function max return the index of maximum values
%of A(k:n,1:k) so we should change it into the value of
%matrix A
p(k)=u; %record the index u
%exchange the row of k and u
t1 = A(k,k:n); %temporary variable t1
A(k,k:n) = A(u,k:n);
A(u,k:n) = t1;

t2 = b(k); %temporary variable t2
b(k) = b(u);
b(u) = t2;
% Gauss elimination method
if A(k,k) ~= 0
rows=k+1:n
A(rows,k)=A(rows,k)/A(k,k);
A(rows,rows)=A(rows,rows)-A(rows,k)*A(k,k);
L(rows,rows)=A(rows,rows);
end

end

% calculate the matrix U
for k=2:n
A(k,1:k-1)=0;
end

二、求解三角方程组的程序:
function x= Eqn_Root(A,b);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate the solution of upper triangular equations set Ax=b
% Nov 26,2008
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[m,n]=size(A); %get the size of matrix 'A'
%x(n)=b(n)/A(n,n); %calculate x(n)
% calculate the solution
for i = n : -1 : 1
t = 0;
for j = n : -1 : i+1
t = t+A(i,j)*x(j);
end
x(i) = (b(i)-t)/A(i,i);
end

三、主程序:
function Examples_Eqn_Root
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use the Gauss method to solve the linear equations Ax=b
% Nov 26, 2008
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A = [ 1 3 6 8 9 2; %input the value of 'A'
2 5 3 1 6 3;
3 6 1 2 8 5;
2 6 8 9 3 8;
5 8 9 3 2 3;
3 5 8 1 7 2];
b= [2 -3 2 55 16 -6]; %input the value of 'b'
b = b'; %take the transpose of 'b'
[A,b]= Gauss(A,b) %change the matrix 'A' into upper triangular matrix
%return the new array 'b'
b = b'
x= Eqn_Root(A,b) %calculate the upper triangular quations set
end
如题。。。翻译下注释就可以了
不要用在线翻译。。。稍微知道点的来回答下= =

一楼翻译是什么东西啊?直接复制到google在线里翻译出来,还累?我看别人要想看懂才真是累!给楼主翻译了下,如果楼主对高斯消去法比较了解的话就很容易懂。

%用高斯消去法把矩阵A转换为上三角阵
[m,n]=size(A); %获得A的行和列分别存入m和n中
% 列主元素消去法
for k=1:n-1
[v,u]=max(abs(A(k:n,k))); %选出A的第k列中绝对值最大元素存入v, 而u是记录多少的行或列,并取最大值,比如有m行,n列,且n>m,则u=n
%计算矩阵A中这些元素 A(k:n,1:k)
u=u+k-1;
%因为函数返回矩阵A(k:n,1:k)中最大元素,因此我们应该变换矩阵A的值,下面进行变换
p(k)=u; %用p(k)来记录u的值
%交换第k行和第u行的数据
t1 = A(k,k:n); %为了实现交换,定义一个中间变量t1
A(k,k:n) = A(u,k:n);
A(u,k:n) = t1;

t2 = b(k); %t2是一个临时变量
b(k) = b(u);
b(u) = t2;
%前面主要是对A进行变换,即在进行消去之前,第一次先比较A中第一列绝对值最大的元素,然后再将第一列中有最大元素的那行交换到第1行,
然后用下面方法进行消去,将除第一行外的元素的第一列都消去为0;第二次然后比较A中第二列元素(此时第一行不用参与比较),将最大元素那行
交换到第二行,将3,4,5…行的第二列也变为0;依此类推,直到把A变为上三角阵,这也是为什么下面的A(k,k) ~= 0不为0的原因(有0就可省去一步)
% 高斯消去法
if A(k,k) ~= 0
%下面是高斯法消去的主要步骤,可参考有关书看看。
rows=k+1:n
A(rows,k)=A(rows,k)/A(k,k);
A(rows,rows)=A(rows,rows)-A(rows,k)*A(k,k);
L(rows,rows)=A(rows,rows);
end

end

% 计算矩阵 U
for k=2:n
A(k,1:k-1)=0;
end

二、求解三角方程组的程序:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 用转换为三角矩阵法来求解Ax=b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[m,n]=size(A); %获得A的行和列分别存入m和n中
%x(n)=b(n)/A(n,n); %计算x(n)
% 下面进行求解
for i = n : -1 : 1
t = 0;
for j = n : -1 : i+1
t = t+A(i,j)*x(j);
end
x(i) = (b(i)-t)/A(i,i);
end

三、主程序:
function Examples_Eqn_Root
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 用高斯消去法求解线性方程 Ax=b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A = [ 1 3 6 8 9 2; %i输入矩阵 'A'
2 5 3 1 6 3;
3 6 1 2 8 5;
2 6 8 9 3 8;
5 8 9 3 2 3;
3 5 8 1 7 2];
b= [2 -3 2 55 16 -6]; %i输入 'b'
b = b'; %转换 'b'
[A,b]= Gauss(A,b) %把[A b]变换为A为上三角阵的形式
%同时将变换后的'b'返还给b
b = b'
x= Eqn_Root(A,b) %通过三角阵方法求解

end
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-12-20
use Gaussian elimination method to change 'A' into upper triangular matrix
用高斯消去法改变'甲'到上三角矩阵
get the size of matrix 'A'
获取矩阵的大小'甲'
column pivotal elimination method
列关键消除法
select the maximum element into the kth %column of matrix A
选择到第k最大元素%列矩阵A
because function max return the index of maximum values
of A(k:n,1:k) so we should change it into the value of matrix A
因为函数返回的最大最大值指数
对甲(金:无,1:十一),所以我们要变的价值是高斯消去法

p(k)=u; %record the index u
%exchange the row of k and u
t1 = A(k,k:n); %temporary variable t1
A(k,k:n) = A(u,k:n);
A(u,k:n) = t1;

t2 = b(k); %temporary variable t2
b(k) = b(u);
b(u) = t2;
% Gauss elimination method
if A(k,k) ~= 0
rows=k+1:n
A(rows,k)=A(rows,k)/A(k,k);
A(rows,rows)=A(rows,rows)-A(rows,k)*A(k,k);
L(rows,rows)=A(rows,rows);
end

P(下十一)= ü;%记录指数ü
%k的交流和U行
t1 =甲(金,钾:不适用);%的临时变量t1
甲(金,钾:不适用)=甲(ü,钾:n)的;
甲(ü,钾:不适用)= T1处理器

乃=乙(十一);%的临时变量t2
乙(十一)=的B(U);
的B(U)= t2;
%高斯消去法
如果A(金,十一)〜= 0
行= k +1的:无
甲(行,钾)=甲(行,钾)/阿(金,k)的;
甲(行,行)=甲(行,行)阿(行,k)的*甲(金,k)的;
蜇(行,行)=甲(行,行);


function x= Eqn_Root(A,b);函数x = Eqn_Root(甲,乙);

Nov 26,2008 26,2008年11月
[m,n]=size(A); %get the size of matrix 'A'
%x(n)=b(n)/A(n,n); %calculate x(n)
% calculate the solution
for i = n : -1 : 1
t = 0;
for j = n : -1 : i+1
t = t+A(i,j)*x(j);

use the Gauss method to solve the linear equations Ax=b
% Nov 26, 2008
使用高斯方法来求解线性方程组Ax = b的
%08年11月26日
end
x(i) = (b(i)-t)/A(i,i);
译:
[的m,n] =大小(A组);%获取矩阵的大小'甲'
%×(n)的二B(北)/阿(不适用,n)的;%计算×(n)的
%计算解决方案
对于i =信噪比:-1:1
t = 0时;
办理J = ñ:-1:我一
吨=吨+ A(一,十)* ×(j)条;
末端
×(一)=(b(一)-吨)/阿(一,一);

A = [ 1 3 6 8 9 2; %input the value of 'A'
2 5 3 1 6 3;
3 6 1 2 8 5;
2 6 8 9 3 8;
5 8 9 3 2 3;
3 5 8 1 7 2];
b= [2 -3 2 55 16 -6]; %input the value of 'b'
b = b'; %take the transpose of 'b'
[A,b]= Gauss(A,b) %change the matrix 'A' into upper triangular matrix
%return the new array 'b'
b = b'
x= Eqn_Root(A,b) %calculate the upper triangular quations set
end
阿= [1 3 6 8 9 2%的投入的价值,'甲'
2 5 3 1 6 3;
3 6 1 2 8 5;
2 6 8 9 3 8;
5 8 9 3 2 3;
3 5 8 1 7 2];
乙= [2 -3 2 55 16 -6];%投入的'b值'
b = b的';%采取'转b'
[甲,乙] =高斯(甲,乙)%,改变矩阵'甲'到上三角矩阵
%的回报率的新数组的B
b = b的'
x = Eqn_Root(甲,乙)%计算上设置三角quations
结束

好累啊,很难翻译,但运用您强大的思维理解能力应该能知道大概意思 呼呼~~

关于matlab高斯消去法,翻译下注释就可以了,在线等
用高斯消去法把矩阵A转换为上三角阵 [m,n]=size(A); %获得A的行和列分别存入m和n中 列主元素消去法 for k=1:n-1 [v,u]=max(abs(A(k:n,k))); %选出A的第k列中绝对值最大元素存入v, 而u是记录多少的行或列,并取最大值,比如有m行,n列,且n>m,则u=n 计算矩阵A...

MATLAB实现高斯列主元消去法的问题
按你的思路修改的,我试了一两个例子,还行。function x = gauss(A,b)[n,n]= size(A);x = zeros(n,1);Aug = [A,b];增广矩阵 for k = 1:n-1 [piv,r]= max(abs(Aug(k:n,k)));找列主元所在子矩阵的行r r = r + k - 1;列主元所在大矩阵的行 if r>k temp=Aug(k,...

matlab中用的高斯消元法怎么使用!
function x=gaussLinearEquation(A,b)高斯法解线性方程Ax=b disp('原方程为AX=b:')A b disp('---')n=length(b);eps=10^-2;for k=1:n-1 找列主元 [mainElement,index]=max(abs(A(k:n,k)));index=index+k-1;%index在A(k:n,k)中的行号转换为在A中的行号 if abs(mainElemen...

用MATLAB 实现列主元高斯消去法
function x=gauss_lie(A,b)采用高斯列主元法求解方程组Ax=b n=length(b);p=1:n;lu=A;y=[];for k=1:n [c,i]=max(abs(lu(k:n,k)));ik=i+k-1;if ik~=k m=p(k);p(k)=p(ik);p(ik)=m;ck=lu(k,:);lu(k,:)=lu(ik,:);lu(ik,:)=ck;end if k==n break;e...

用matlab 编写高斯顺序消元法求解下面方程组的程序及并计算结果_百度知 ...
function [x,XA]=GaussXQByOrder(A,b)高斯顺序消元法 N = size(A);n = N(1);for i=1:(n-1)for j=(i+1):n if(A(i,i)==0)disp('对角元素为0!'); %防止对角元素为0 return;end l = A(j,i);m = A(i,i);A(j,1:n)=A(j,1:n)-l*A(i,1:n)\/m; %...

MATLAB 如何使用高斯消去法解出方程式
高斯消去法解方程 Ax = B NA = size(A,2);[NB1,NB] = size(B);if NB1 ~= NA,error('A 和 b 维数不匹配');end N = NA + NB;AB = [A(1:NA,1:NA) B(1:NA,1:NB)]; % 增广矩阵 epss = eps*ones(NA,1);for k = 1:NA [akk,kx] = max(abs(AB(k:NA,k))....

用高斯消元法解线性方程组 的MATLAB程序
inv)求解线性方程组,输入如下代码:close all; clear all; clc,% MATLAB求逆法(inv)求解线性方程组,% A是线性方程组等号左边系数构成的矩阵。5、保存和运行上述代码,利用求逆法(inv)得到线性方程组的解如下。6、最后,可以看到左除法(\\)和求逆法(inv)求得的线性方程组解是一样的。

matlab 用列主元高斯消去法求逆矩阵
程序如下 function x=gauss(A,b) %高斯求解方程组 x=gauss(A,b)n=length(A);a=[A,b];for k=1:n-1 maxa=max(abs(a(k:n,k)));if maxa==0 return;end for i=k:n if abs(a(i,k))==maxa y=a(i,k:n+1);a(i,k:n+1)=a(k,k:n+1);a(k,k:n+1)=y;break;end...

如何用matlab语言实现用高斯消去法求矩阵的逆?
if Row ~= Col '线性方程组的系数矩阵非方阵,程序终止'return end if det(a)==0 '线性方程组的系数矩阵行列式为0'return end Gauss消元法 for k=1:n-1 if a (k,k) ==0 '对角线元素a(%1d,%1d)为零,程序终止'return end for i =k+1:n l(i,k) = a(i,k)\/a(k,k);for ...

如何编写用高斯约旦全主消元法求矩阵的逆矩阵的MATLAB程序
1\/x)+1]为初等函数,其定义域为x≠0,所以当x≠0时,函数皆连续.∵lim[x-->0-][2^(1\/x)-1]\/[2^(1\/x)+1]=-1 ∵lim[x-->0+][2^(1\/x)-1]\/[2^(1\/x)+1]=lim[x-->0+][1-2^(-1\/x)]\/[1+2^(-1\/x)]=1 ∴x=0是第一类间断点,是阶跃间断点,跳跃度是2.

相似回答