How do I apply a tolerance to my code

1 回表示 (過去 30 日間)
Nicholas Gresham
Nicholas Gresham 2020 年 4 月 22 日
コメント済み: Josh Taylor 2020 年 4 月 27 日
Outline
The singularityTest function will test whether a matrix is singular (i.e., not invertible). If it is singular, the output should be 1. Otherwise, the output should be 0. The input, A, can be any n × n matrix.
Your code needs to take into consideration very small errors that could occur due to floating point arithmetic (apply a tolerance of 10-10).
This is my code
function result = singularityTest(A)
if det(A)== 0
result = 1;
else
result = 0;
end
end
Question
How do I apply the tolerance (10-10) to my code

採用された回答

darova
darova 2020 年 4 月 22 日
Use this trick
  2 件のコメント
Nicholas Gresham
Nicholas Gresham 2020 年 4 月 25 日
Yes that worked thankyou for your help
Josh Taylor
Josh Taylor 2020 年 4 月 27 日
ayee Nicholas i see what this question is from XD

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElectrical Block Libraries についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by