sigfigstr - printing with the appropriate number of sigfigs
This function formats strings based on the desired number of significant figures rather than the number of decimal places. It is inspired by work on stack overflow (https://stackoverflow.com/questions/21354701/matlab-fprintf-to-keep-significant-figures-and-rightmost-zeroes).
Here is an example of it in action
>> sigfigstr(.000012431634,3)
ans = '0.0000124'
>> sigfigstr(26666,3)
ans = '26700'
I welcome any feedback or notes of when it doesn't work.
引用
Eric Homer (2024). sigfigstr - printing with the appropriate number of sigfigs (https://www.mathworks.com/matlabcentral/fileexchange/87327-sigfigstr-printing-with-the-appropriate-number-of-sigfigs), MATLAB Central File Exchange. 取得済み .
MATLAB リリースの互換性
プラットフォームの互換性
Windows macOS Linuxタグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!