How can we let Matlab to choose the decimal place?
Show older comments
Hi there, I would like to ask if like my answer is 1.11111 and my error is 0.001234, so suppose I should write my answer like 1.111+-0.001. So is there any output method so that MATLAB can know that it should display the first non-zero digit for the error and the answer should have the same decimal place as the error?
Accepted Answer
More Answers (1)
Walter Roberson
on 24 Nov 2011
0 votes
No, there is no MATLAB output method that does that. You would have to program one.
Examine the behavior of the floor() and ceil() of log10(error); you will probably find that you need a minimum of 1 "if" condition, perhaps even 2. Watch out for values above or below 1, and watch out for exact powers of 10 -- e.g., 99 vs 100 vs 101 and .099 vs .100 vs .101 .
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!