フィルターのクリア

Display double number with 6 digits exactly

5 ビュー (過去 30 日間)
Askic V
Askic V 2022 年 10 月 17 日
コメント済み: Askic V 2022 年 10 月 21 日
Hello,
I would like to create a string that will contain a double number. This number should be represented with 6 digits exactly.
For example:
x = 12.45;
str_x = sprintf('The number is %f\n', x);
should output 12.4500

採用された回答

Stephen23
Stephen23 2022 年 10 月 19 日
sprintf('The number is %#.6g', 12.45)
ans = 'The number is 12.4500'
sprintf('The number is %#.6g', 2)
ans = 'The number is 2.00000'
  1 件のコメント
Askic V
Askic V 2022 年 10 月 21 日
Thank you Stephen!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by