How do I apply a tolerance to my code

1 visualización (últimos 30 días)
Nicholas Gresham
Nicholas Gresham el 22 de Abr. de 2020
Comentada: Josh Taylor el 27 de Abr. de 2020
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

Respuesta aceptada

darova
darova el 22 de Abr. de 2020
Use this trick
  2 comentarios
Nicholas Gresham
Nicholas Gresham el 25 de Abr. de 2020
Yes that worked thankyou for your help
Josh Taylor
Josh Taylor el 27 de Abr. de 2020
ayee Nicholas i see what this question is from XD

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Electrical Block Libraries en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by