変数の形式で 2 つの行列があり、これA
はb
私の matlab 関数への入力です (以下に掲載)。結果、行列から行列の逆演算(行列除算)で使用する有効数字を計算したいと思い
ます。ただし、このアプローチを開始するために (matlab または数学的に) どこから始めればよいかわかりません。ヘルプ?A
b
より多くのコンテキスト、正方線形システムを使用して(Ax=b)
、それが特異か非特異かを見て、解決策を見つけようとしています。
% x = answer
% y = 0 if no solution, 1 if nonsingular, 2 if many solutions
% z = p is number of sig figs
%
function [ x, y, z ] = squareLinSysSolv(A, b)
if det(A) == 0
% Matrix is singular and therefor many solutions
x = A\b;
y = 0; % Used as place holder to compile
z = 5; % Used as place holder to compile
elseif det(A) ~= 0
% Matrix does not equal to zero (perhaps a number very close to it or
% far from it) and therefor has a unique solution.
x = A\b;
y = 1; % Used as place holder to compile
z = 5; % Used as place holder to compile
end
end
編集:
少し明確にするために、 z は、計算された有効数字の10進数に近似する(天井値または下限値)整数である必要があります。A\b
テスト ケース:
期待される内容のテスト/スペック シート。A
とは両方ともb
行列であり、結果はそのようになるはずです。
A =
1.5000 2.3000 7.9000
6.1000 3.2000 13.0000
13.0000 21.0000 76.0000
b =
1
3
5
>> [x,y,z] = squareLinSysSolv(A,b)
% the result of x = A\b
x =
0.8580
3.0118
-0.9132
% determinant is not equal to zero
y =
1
% Amount of sig figs/precision in calculation
z =
15