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

Status
Not open for further replies.

vickyuet

Member level 2
Joined
Oct 3, 2006
Messages
50
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
pakistan
Activity points
1,691
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
 

Read help on "vpa" function - variable precision arithmetics
 

@ 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
 

Indeed.

So maybe there is only one way - rounding

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

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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…