Formatting floating and integer signed numbers

4 ビュー (過去 30 日間)
Saikat Banerjee
Saikat Banerjee 2020 年 6 月 12 日
コメント済み: Saikat Banerjee 2020 年 6 月 12 日
Suppose a=5 and b=-6. If I use sprintf and write sprintf("℅0.2f+℅0.2f°,a,b) we get 5.00+-6.00 as answer and not 5.00-6.00. I would like to display the answer as 5.00-6.00. How to do it?

採用された回答

James Tursa
James Tursa 2020 年 6 月 12 日
編集済み: James Tursa 2020 年 6 月 12 日
sprintf("%0.2f%+0.2f",a,b)
Having the + inside the %format stuff forces the sign to print.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by