I want to reduce accuracy and precision to 3 digits.
Afficher commentaires plus anciens
Réponses (3)
Praveen Iyyappan Valsala
le 25 Avr 2018
I don't know any inbulit function which can do that. But, you can try something like below
trun=@(num,Ndigits)floor(a*10^Ndigits)/10^Ndigits;
trun_a=trun(a,2);
Walter Roberson
le 25 Avr 2018
0 votes
No, there is no built-in way.
You can use the symbolic toolbox with digits set to 3, but that will round rather than truncate.
1 commentaire
Stephen23
le 26 Avr 2018
Note that setting the digits does not mean that calculations will be performed with exactly that precision, because calculations may use guard digits.
Tom Wenk
le 25 Avr 2018
0 votes
Like Walter Roberson stated, I think you have to use the symbolic toolbox for that.
Maybe this function from the toolbox can help you: https://de.mathworks.com/help/symbolic/digits.html
3 commentaires
Stephen23
le 26 Avr 2018
Note that setting the digits does not mean that calculations will be performed with exactly that precision, because calculations may use guard digits.
Tom Wenk
le 2 Mai 2018
I see, but is there an other way to do it then?
Walter Roberson
le 2 Mai 2018
For addition: multiply the original values by 100, take floor() or fix(). Do the addition. Divide the result by 100.
Catégories
En savoir plus sur Code Performance 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!