Hello,
I am looking for a format such that:
fprintf( format , 1.1111111); gives 1.11
fprintf( format , 11.111111); gives 11.1
fprintf( format , 111.11111); gives 111
That is 3 digits in total regadless of the decimal point, thanks!

 採用された回答

Walter Roberson
Walter Roberson 2020 年 8 月 21 日

0 投票

%.3g

その他の回答 (1 件)

Sara Boznik
Sara Boznik 2020 年 8 月 21 日

0 投票

Hi
I suggest you that you use:
fprintf('%.3g',1.111111)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Mobile についてさらに検索

製品

リリース

R2019b

質問済み:

J T
2020 年 8 月 21 日

回答済み:

2020 年 8 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by