Round values after the decimal point
Useful helper function that rounds scalars, vectors or matrices smaller/bigger than zero at a defined place after the decimal point.
Needs two input arguments to work properly: out = sRound(val, precision)
Usage: out = sRound(val, prec)
Example1: a = sRound(0.46,1);
a = 0.5000
Example2: b = sRound(-5.478,2);
b = -5.4800
Example3: c = sRound([0.8236 2.6958 3.3171 0.9502 0.0364], 3);
c = 0.8240 2.6960 3.3170 0.9500 0.0360 0.34330
Example4: d = sRound([-0.1694 -1.4351 0.3925; -0.0522 -2.6 1.3433], 3);
d = -0.1690 -1.4350 0.3930
-0.0520 -2.6000 1.3430
Example5: e = sRound(3.5);
e = 4
This code should run with every MATLAB version.
Zitieren als
Tobias Otto (2025). Round values after the decimal point (https://www.mathworks.com/matlabcentral/fileexchange/31209-round-values-after-the-decimal-point), MATLAB Central File Exchange. Abgerufen.
Kompatibilität der MATLAB-Version
Plattform-Kompatibilität
Windows macOS LinuxKategorien
Tags
Quellenangaben
Inspiriert: Average_precision(Outputs,test_target)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.3.0.0 | More user info and error handling |
||
1.1.0.0 | Added more user info |
||
1.0.0.0 |