scientific notation in each element

56 ビュー (過去 30 日間)
covariant_cat
covariant_cat 2019 年 9 月 25 日
コメント済み: covariant_cat 2019 年 9 月 26 日
Is it possible to display scientific notation independantly in each element of the matrix?
Currently matlab has a global exponential term:
a = [2*10^1 5*10^30]
a =
1.0e+30 *
0.0000 5.0000
The problem is that if there is even just one huge number in the matrix, the other numbers are all displayed as 0.0000 and contain 0 information
A better display would be:
a = [2*10^1 5*10^30]
a =
2.000e+01 5.000e+30
This is what Numpy does and I think it makes much more sense.
Of course, the original display may be useful as a warning of having some undesired large numbers in the matrix so that we can be aware of some numerical bugs sooner.
Perhaps the ideal solution is to provide separate functions to display things like:
disp1(a)
a =
1.0e+30 *
0.0000 5.0000
disp2(a)
a =
2.000e+01 5.000e+30
  1 件のコメント
dpb
dpb 2019 年 9 月 25 日
Yeah, that is kinda' a bum output choice TMW made.
One can, of course, use a specific output format and fprintf but having to do so is a nuisance, granted.

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

採用された回答

David Goodmanson
David Goodmanson 2019 年 9 月 26 日
編集済み: David Goodmanson 2019 年 9 月 26 日
Hi c^2,
try "format short g" beforehand.
Things stay that way until further notice. To go back to the default you can use "format".
  1 件のコメント
covariant_cat
covariant_cat 2019 年 9 月 26 日
Thanks! That looks good!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by