数値に桁カンマを挿入することは可能ですか?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
数値に3桁カンマを挿入する方法を教えてください。
Akzeptierte Antwort
MathWorks Support Team
am 24 Feb. 2010
カンマを挿入する場合、3桁ずつのグループに分ける必要があります。
下記プログラムをMATLABプログラムとして保存してご利用ください。
または関連ドキュメントよりダウンロードしてご利用ください。
function out = ThousandSep(in)
% Example:
% ThousandSep(1234567)
import java.text.*
v = DecimalFormat;
data = [];
for n=1:length(in)
data{n} = char(v.format(in(n)));
end
out =data;
下記を実行すると、カンマで区切られた文字列が出力されます。
ThousandSep([123456778,2225887])
結果は文字のセル配列となっています。
ans =
'123,456,778' '2,225,887'
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu テキスト ファイル finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!