필터 지우기
필터 지우기

Exponential precision of power engineering format

조회 수: 4 (최근 30일)
Leandro de Oliveira
Leandro de Oliveira 2018년 4월 23일
답변: Harry Dymond 2020년 5월 31일
Hello guys! I have the number 143903542.580052, by default matlab prints 1.439035e+08 but I want to print 143.9035e+06, I've tried so many matlab help links but nothing to do. Is there a way?

답변 (2개)

Star Strider
Star Strider 2018년 4월 23일
For Command Window and ‘tooltip’ formatting, use:
format short eng
or:
format long eng
For printed output (using fprintf or sprintf), I wrote a little utility anonymous function for my own use to do that:
engntn = @(x) [x*10.^(-3*floor(log10(abs(x))/3)) 3*floor(log10(abs(x))/3)]; % Engineering Notation Mantissa & Exponent
Result2 = sprintf('%.4fE%+04d', engntn(Q1))
for example:
Q1 =
143903542.580052
Result2 =
'143.9035E+006'
  댓글 수: 2
Leandro de Oliveira
Leandro de Oliveira 2018년 4월 23일
Thank you, I hope Matlab implement some function like yours in the future.
Star Strider
Star Strider 2018년 4월 23일

My pleasure.

If my Answer helped you solve your problem, please Accept it!

댓글을 달려면 로그인하십시오.


Harry Dymond
Harry Dymond 2020년 5월 31일
My FEX submission num2eng will do this for printed output. It handles edge cases such as Inf and NaN inputs, has extensive formatting control for the output, and offers the option of SI prefixes instead of engineering notation.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by