フィルターのクリア

How can I display high precision number in engineering format?

2 ビュー (過去 30 日間)
Sree Ranjini
Sree Ranjini 2016 年 10 月 14 日
編集済み: Walter Roberson 2016 年 10 月 16 日
I need to display my results in engineering format with large exponential values( for eg. 3.14159e-070). 'format longE' doesn't helps in this case. I used vpa function but it displays the result in expanded format (for eg. 0.000000000000000000000000000000000000000000000000000000000000000000000000003141592653589793299). How can I display my results in exponential form with high negative powers? Thanks in advance.

回答 (1 件)

Star Strider
Star Strider 2016 年 10 月 14 日
I wrote a utility function for my own use that you may find useful:
engstr = @(x) [x*10.^(-3*floor(log10(abs(x))/3)) 3*floor(log10(abs(x))/3)];
Q1 = Your_Number_Here;
Result2 = sprintf('%.4fe%+04d', engstr(Q1))
The ‘engstr’ function calculates the mantissa and exponent as a (1x2) vector. The ‘Result2’ assignment demonstrates a way to print them.
  3 件のコメント
Star Strider
Star Strider 2016 年 10 月 16 日
My pleasure.
Use double instead of vpa, or change the ‘Result2’ assignment to:
Result2 = sprintf('%.4fe%+04d', engstr(double(Q1)))
That should work.
Walter Roberson
Walter Roberson 2016 年 10 月 16 日
編集済み: Walter Roberson 2016 年 10 月 16 日
It won't display the results in high precision with accuracy. The question is about reformatting a high precision symbolic number to still have high precision but engineering format. (I think. The text and the tags are not entirely clear about it.)

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

カテゴリ

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