How do I apply a tolerance to my code

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 个评论

Yes that worked thankyou for your help
ayee Nicholas i see what this question is from XD

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Electrical Block Libraries 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by