clcondno.m

来自「Programs for the book Advanced Engineeri」· M 代码 · 共 18 行

M
18
字号
% CLCONDNO.M Solve A*x=b for A a 5x5 Hilbert matrix
%  x=[1 1 1 1 1] is answer; xcomp is computed vector
% OUTPUT: Condition number (condA) and xerror=xcomp-x
% 
format rat	   % Show rational values
format compact     %   and suppress blank lines
A=hilb(5);         % Hilbert matrix
b=[137/60 87/60 459/420 743/840 1879/2520]';
x=[1 1 1 1 1];     % Exact answer	
% Check condition number and solve
fprintf('Condition number and error in xcomp:\n')
condA=cond(A)      % Display condition number
format long        % Format decimal values
xcomp=A\b;         % Computed value of solution
fprintf('Error in calculated value xcomp(I), I=1,5\n')
xerror=xcomp - x'

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?