Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc

上传人:b****2 文档编号:1399158 上传时间:2022-10-22 格式:DOC 页数:1 大小:22KB
下载 相关 举报
Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc_第1页
第1页 / 共1页
亲,该文档总共1页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc

《Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc》由会员分享,可在线阅读,更多相关《Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc(1页珍藏版)》请在冰豆网上搜索。

Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc

Matlab线性方程组的迭代解法Gauss-Seidel迭代法实验报告

1.熟悉Gauss-Seidel迭代法,并编写Matlab程序

function[y,n]=gauss_seidel(A,b,x0,eps)

%gaussseideliterativemethodtosolveAx=b

ifnargin==3

eps=1e-6;

elseifnargin<3

error;

return

end

D=diag(diag(A));

L=-tril(A,-1);

U=-triu(A,1);

G=(D-L)\L;

f=(D-L)\b;

y=G*x0+f;

n=1;

whilenorm(y-x0)>=eps

x0=y;

y=G*x0+f;

n=n+1;

end

2.

用Gauss-Seidel迭代法求解线性方程组。

输入:

>>A=[430;33-1;0-14];

>>b=[24;30;-24];

>>x0=[0;0;0];

>>[y,n]=gauss_seidel(A,b,x0)

输出:

y=

6

-2

-7

n=

4

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1