Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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
51
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
 

Mityan

Full Member level 5
Joined
Jul 11, 2012
Messages
281
Helped
48
Reputation
96
Reaction score
47
Trophy points
1,308
Activity points
2,835
Read help on "vpa" function - variable precision arithmetics
 

vickyuet

Member level 2
Joined
Oct 3, 2006
Messages
51
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
pakistan
Activity points
1,691
@ 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
Joined
Jul 11, 2012
Messages
281
Helped
48
Reputation
96
Reaction score
47
Trophy points
1,308
Activity points
2,835
Indeed.

So maybe there is only one way - rounding

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

FboDigit

Member level 1
Joined
Jun 19, 2012
Messages
38
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Canada
Activity points
1,502
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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top