📄 ex317wif.m
字号:
% EX317WIF.M 20 x 20 hilbert% Test the condition number and error in Hilb20*x=b% x=[1 1 1 ....1]clear % Clear variables and the screenclcformat rat % Rational numbersHilb20=hilb(20); % 20 x 20% Look at a few entriesHilrow1=Hilb20(1,:) % First row 1 1/2 ...... 1/n pause % Strike a key to continue Hilrow20=Hilb20(20,:) % 20th row 1/20 ..... 1/(2n-1)pause%% Find b in Hilb20 * x =b %xexact=ones(20,1); % Column matrixb=Hilb20*xexact % Constant (displayed)pause%% Let MATLAB try and solve it and then display errors%format long ecnHilb20 = cond(Hilb20) % Condition Numberpausexcomp = Hilb20\b % Computed value of solutionpause % Note MATLAB's messagefprintf('Error in calculated value\n')xerror=xcomp - xexact % Display error in each component%pauseformat shortxcomp % Easier to understand the error%% Display error in bcomp to see how far it is off %pausebcomp = Hilb20*xcomp; % Look at bcomp if desired errorb=bcomp-b%% The result is misleading bcomp is close but xcomp is way off%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -