Matlab tolerance for a value that is Very very small i.e approximately Zero....

Status
Not open for further replies.

vickyuet

Member level 2
Due to high Precision of MATLAB,it often treats values very very small i.e 2.4493e-15 not equal to zero that we usually interpret as zero in our calculations as well as programs.How is it possible in programming to cater these things during using Matlab functions?Is it possible to define our threshold with matlab functions so that any value below this would be treated as zero.....I mean defining a tolerance.....
For Example: The value is approx zero for all real calculation yet find treats it as non-zero due to its MATLAB precision :?:
find(2.44929e-15)

ans =

1

Mityan

Full Member level 5
Read help on "vpa" function - variable precision arithmetics

vickyuet

Member level 2
@ Mityan:
I want to make the smaller value say .0000000000000005 to be treated as zero not to set the precision points for a variable....
vpa(.00000000000000005,5) yields

ans =

.50000e-16

Mityan

Full Member level 5
Indeed.

So maybe there is only one way - rounding

>> roundn(.00000000000000005,-4)
ans =
0

FboDigit

Member level 1
Create a function !

Code:
Function [your_var] ....
your_tolerance = xxx  %choose the smallest acceptable value
if (your_var < your_tolerance)
return 0
else
return your_var

Status
Not open for further replies.