File Exchange

image thumbnail


version (436 Bytes) by Taesam Lee


Updated 13 May 2016

View License

make the double data to be with n digit decimal data
% It is necessary when you plot the value as a text box or print it

Cite As

Taesam Lee (2021). decimal(X,ndecimal,is_round) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Stephen Cobeldick

This is somehow a rite-of-passage for MATLAB learners. Does everyone write one of these? There are certainly plenty of FEX already.

This is a reasonable submission: neat and tidy with a clear description.

A few tips:

* Do not put an empty line before the "Examples". Instead you should put one single '%' sign to make that line a comment. You will see why when you call "help decimal".
* The function name "decimal" is a bit too broad: this function does _rounding_, so the name should perhaps reflect that.
* The input argument |is_round| is used incorrectly to select the |floor| operation.
* The explanation that this function is "necessary" when printing values is not true: the standard |fprintf| is quite good at rounding to decimal places:

>> fprintf('%.*f\n', 1, 20/3)
>> fprintf('%.*f\n', 3, 20/3)

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!