Numeric miscalculation on the 14th decimal place
Afficher commentaires plus anciens
I run a model based on casual differential equations and solved them with ode45. I calculated the slope of a solution of one of the equations with log diff(values) and calculated the mean from that. I wanted to put this mean slope in relation to other slopes I got from different calculations. Matlab does not display the exact value but seems to keep it in its working memory until the 14th decimal place(?). When I use this slope as it is to do some basic calculations, everything is fine. For example for the default slope I want to compare all my other slopes with it which is -0.026097431101009
When I do the following calculation:
deltaslope=((sloperun*100)/slopedefaultvalue)-100
Matlab seems to do a miscalculation on the 14th decimal place; one of my calculations include that I do it with the already default slope which should lead to 0 (because there is no difference) but it leads to 4.263256414560601e-14 as a difference that shouldn't be there. I actually need the basic calculation to put it into context. I guess matlab just tries to be as exact as possible and just produces this kind of error because it just can't calculate all decimal places. Does somebody has an idea how to avoid that? Is there a setting I could change to force matlab to just keep one decimal place?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!