필터 지우기
필터 지우기

Selectively setting significant digits in display

조회 수: 8 (최근 30일)
ANUBHAV SINHA
ANUBHAV SINHA 2011년 2월 5일
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.

채택된 답변

Jiro Doke
Jiro Doke 2011년 2월 5일
Make use of fprintf.
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 CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by