马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
function x=naivgauss(A,b);
n=length(b); x=zeros(n,1);
for k=1:n-1
for i=k+1:n
xmult=A(i,j)/A(k,k);
for j=k+1:n
A(i,j)=A(i,j)-xmult*A(i,j);
end
b(i)=b(i)-xmult*b(k);
end
end
% back substitution
x(n)=b(n)/A(n,n);
for i=n-1:-1:1
sum=b(i);
for j=i+1:n
sum=sum-A(i,j)*x(j);
end
x(i)=sum/A(i,j);
end
>> A=[0.001 2.000 3.000;-1.000 3.712 4.623;-2.000 1.072 5.643];
b=[1.000;2.000;3.000];
>> naivgauss(A,b)
??? Error: File: naivgauss.m Line: 6 Column: 13
"j" previously appeared to be used as a function, conflicting with its use here as the name of a variable.
A possible cause of this error is that you forgot to initialize the
variable, or you have initialized it implicitly using load or eval.
不知道上面的程序错误什么意思?请各位大侠帮忙解释一下!!!谢了先! |