資源簡介
MATLAB實(shí)現(xiàn)高斯賽德爾迭代法MATLAB實(shí)現(xiàn)高斯賽德爾迭代法
代碼片段和文件信息
%高斯賽德爾迭代
clear?all;
close?all;
clc;
tic
format?longe?
disp(‘請輸入?yún)?shù)‘);
K=input(‘維數(shù)K=‘);
tic
A=100*rand(K);%?A元素是0-100
for?i=1:K
????A(ii)=sum(abs(A(i:)))+25*rand(1);?%對(duì)角占優(yōu)的量為0~25
end
b=zeros(K1);
for?i=1:K;
????x=0;
????for?r=1:K;
????x=x+A(ir);
????end
????b(i1)=x;
end???%產(chǎn)生b矩陣,b中的元素為A中對(duì)應(yīng)行的和,目的是使方程解全為?1
jd=input(‘控制精度j
評(píng)論
共有 條評(píng)論