ThousandSep

バージョン 1.1.0.0 (3.63 KB) 作成者: Jan
Convert number to string with thousands separators
ダウンロード: 176
更新 2015/5/25

ライセンスの表示

ThousandSep - Number as string with separators every 3rd digit
S = ThousandSep(N, FSpec, Sep)
INPUT:
N: Numbers, all classes accepted by SPRINTF, scalar or array.
FSpec: Format specifier for SPRINTF. Optional, default: '%.16g'
Sep: Character as separator. Optional, default: ,
OUTPUT:
S: String if N is a scalar, otherwise a cell string.
EXAMPLE:
ThousandSep(1234567.2345) % '1,234,567.2345'
ThousandSep(1234, char(39)) % '1'234'
ThousandSep([2.3, 1234], ',') % {'2.3', '1,234'}
ThousandSep(-1234, '%9.1f', ',') % ' -1,234.0'

NOTES:
* Alternative java call, which is about 20% slower (Matlab R2011b/64/Win7):
nf = java.text.DecimalFormat;
S = nf.format(1234567.890123)
* Matlab 6: The code must be modified to run under Matlab 6. See the comment
in the subfunction ToString.

Tested: Matlab 7.7, 7.8, 7.13, WinXP/32, Win7/64

引用

Jan (2024). ThousandSep (https://www.mathworks.com/matlabcentral/fileexchange/50968-thousandsep), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2011b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCharacters and Strings についてさらに検索
タグ タグを追加
謝辞

ヒントを与えたファイル: Tugas 2

Community Treasure Hunt

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

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

Default character adjusted, minor changes in the help section

1.0.0.0