Displaying a value using fprintf with certain number of decimals.
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to display the value of a using fprintf with only two decimals. Given a = 3.870081e+01;
Can you modify my code below to only display two decimals?
fprintf('The answer for a is %d m/s\n', a)
Thanks,
0 件のコメント
採用された回答
Walter Roberson
2021 年 3 月 5 日
format long g
a = rand*10
fprintf('The answer for a is %.2f m/s\n', a)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!