フィルターのクリア

How avoid exponential notation in compose

32 ビュー (過去 30 日間)
Luca Re
Luca Re 2024 年 6 月 22 日
コメント済み: Luca Re 2024 年 6 月 24 日 6:29
hi, i want to avodi exponential notation
compose("%d",daily)
...
"-250"
"1.562500e+02"
"-3.750000e+01"
correct is .
"-250"
"156.25"
"-37.5"

回答 (2 件)

halleyhit
halleyhit 2024 年 6 月 22 日
編集済み: halleyhit 2024 年 6 月 22 日
compose("%f",daily)
or more specific
compose("%4.4f",daily)
seems working

Stephen23
Stephen23 2024 年 6 月 24 日 3:52
編集済み: Stephen23 2024 年 6 月 24 日 4:42
"How avoid exponential notation in compose"
Explanation: the %d conversion is for integer values. Are all of your data integer valued? (hint: no). The documentation states "If you specify a conversion that does not fit the data, such as a text conversion for a numeric value, MATLAB® overrides the specified conversion, and uses %e." By definition the %e conversion uses exponent notation.
Solution: specify a more suitable conversion, e.g. %g
daily = [-250; 156.25; -37.5];
compose("%.5g",daily)
ans = 3x1 string array
"-250" "156.25" "-37.5"
  1 件のコメント
Luca Re
Luca Re 2024 年 6 月 24 日 6:29
thank

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by