指数表示において、e 以降の桁数を指定することはできますか?

9 views (last 30 days)
MathWorks Support Team
MathWorks Support Team on 25 Oct 2013
例えば、 1.000e+000のように、 指数部が 3 桁の数値を 1.000e+00のように指数部を 2 桁にする方法を教えてください。

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Oct 2013
指数表示において、e以降の桁数を指定することはできません。
代替案としては、下記コマンド例にあるように、一度文字列に変換し、指数の桁数を変更した後文字列として出力することで e の桁数を変更することが可能です。
>> a = 120000;
>> b = sprintf('%5.2e',a) % 指数表示
b =
1.20e+005
>> c = num2str(b); % 文字列に変換
>> c(end-2) = []; % 指数の桁を変更
>> sprintf('%s',c) % 文字列として出力
ans =
1.20e+05
なお、指数部の桁数は、R2012a 以降のバージョンでは、デフォルトで以下のように 2 桁表示に変更されています。
>> a = 120000;
>> b = sprintf('%5.2e',a)
b =
1.20e+05

More Answers (0)

Categories

Find more on MATLAB 入門 in Help Center and File Exchange

Products


Release

R2009b

Community Treasure Hunt

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

Start Hunting!