How do I apply a tolerance to my code

조회 수: 3 (최근 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 CenterFile Exchange에서 Switches and Breakers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by