sigfigstr - printing with the appropriate number of sigfigs

バージョン 1.0.1 (1.07 KB) 作成者: Eric Homer
This function is aimed at creating formatted strings of numbers with the appropriate number of significant figures, whether large or small.
ダウンロード 1 件
更新 2021/2/12

ライセンスの表示

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 リリースの互換性
作成: R2020b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.1

Fixed a small bug

1.0.0