0

問題固有のロジックを実行できるように、(スパース A の場合) A\b がいつ失敗したかをプログラムで調べたいと考えています。バックスラッシュ演算子の使用

A\b

コンソールに警告が出力されますが、これらの状態 (特異またはほぼ特異) についてプログラムで知りたいので、問題固有の処理を行うことができます。

高密度システムの場合、私はできる

[soln, cond_recip] = linsolve(A,b);
if cond_recip < 1e-15, ..., end

しかし、linsolve は疎行列では機能せず、行列を高密度化したくありません。

4

1 に答える 1

1

次のことを試してください。

%# temporarily set warning to issue errors (maybe there are others?)
s = warning('error', 'MATLAB:nearlySingularMatrix'); %#ok<CTPCT>

try
    x = magic(4)\[34; 34; 34; 34];
catch ME
    disp(ME.message)
    %#.. problem specific stuff..
end

%# restore warning state
warning(s);
于 2013-04-26T15:37:32.640 に答える