Selectively setting significant digits in display
9 ビュー (過去 30 日間)
古いコメントを表示
Hi, My program outputs a 2-column array of numbers. I wish to display the first column numbers with the precision of 2 decimal places. However, I want the second column to be displayed with a 9 decimal precision. May someone please suggest the way to do this?
Thanks.
0 件のコメント
採用された回答
Jiro Doke
2011 年 2 月 5 日
Here's a short example:
% Create 2-column array of random numbers (0 - 1)
num = rand(10, 2);
% Make some values greater than 10 or 100
num(10) = num(10)+10;
num(15) = num(15)+100;
% Display with specified number of digits
% Note: transpose "num".
fprintf('%6.2f %13.9f\n', num');
This displays:
0.91 0.494173937
0.80 0.779051723
0.10 0.715037078
0.26 0.903720561
0.34 100.890922504
0.68 0.334163053
0.14 0.698745832
0.72 0.197809827
0.11 0.030540946
10.65 0.744074260
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!