欢迎来到天天文库
浏览记录
ID:57395278
大小:12.00 KB
页数:1页
时间:2020-08-15
《Matlab线性方程组的迭代解法Gauss-Seidel迭代法.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Matlab线性方程组的迭代解法Gauss-Seidel迭代法实验报告1.熟悉Gauss-Seidel迭代法,并编写Matlab程序function[y,n]=gauss_seidel(A,b,x0,eps)%gaussseideliterativemethodtosolveAx=bifnargin==3eps=1e-6;elseifnargin<3error;returnendD=diag(diag(A));L=-tril(A,-1);U=-triu(A,1);G=(D-L)L;f=(D-L)b;y
2、=G*x0+f;n=1;whilenorm(y-x0)>=epsx0=y;y=G*x0+f;n=n+1;end2.用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-7n=4
此文档下载收益归作者所有