赞
踩
- clc
- clear
- n = input('请输入矩阵阶数:\n');
- for i = 1:n
- fprintf('请输入矩阵第%d行\n',i);
- A(i,:) = input('');
- end
- A
- B(:,1) = input('请输入B向量:\n');
- B
- for i = 1:n
- x(i) = 0;
- x2(i) = 0;
- end
- for i =1:4
- for j = 1:n
- for k = 1:n
- if j ~= k
- x(j) = x(j)-A(j,k)*x2(k);
- end
- end
- x(j)=x(j) + B(j);
- x(j)=x(j)/A(j,j);
- end
- x2=x;
- for j = 1:n
- x(j)=0;
- end
- fprintf('第%d次迭代结果:\n',i);
- x2
- end
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。