# display result

조회 수: 2 (최근 30일)
Raviteja 2011년 9월 10일
I have a matrix "TRPfeat".
It conisits values of
>>TRPfeat
TRPfeat =
1.0e+003 *
0.0398 2.4990 0.0044 0.0010 0.0493
0.1015 2.4910 0.0033 0.0010 0.1826
0.1038 1.5180 0.0036 0.0010 0.1250
0.0733 0.8220 0.0024 0.0010 0.1180
0.0806 0.7420 0.0036 0.0010 0.1260
0.0465 0.7490 0.0033 0.0010 0.0789
0.0295 2.4040 0.0040 0.0010 0.0446
0.0193 2.4990 0.0037 0.0010 0.0254
My problem is, I dont want to use display multiple of 1.0e+003. Simply I need result with precision 6 digits after the decimal point.
How to do this?

댓글을 달려면 로그인하십시오.

### 답변 (2개)

Fangjun Jiang 2011년 9월 10일
If it is just the matter of display, check doc format. try
format long g
##### 댓글 수: 2없음 표시없음 숨기기
Raviteja 2011년 9월 10일
I need Not only the diplay, the matrix have to store with the formatted values..
Fangjun Jiang 2011년 9월 10일
It is stored with the correct precision. If you want to store it in text file, you can use fprintf() or sprintf(), for example, string=sprintf('%15.6f',TRPfeat(1,1))
Check doc sprintf for details. It's pretty much the same as in C code.

댓글을 달려면 로그인하십시오.

Walter Roberson 2011년 9월 10일
It is not possible with binary floating point numbers to exactly store values that have 6 digits after the decimal point (well, there are a small number that can be stored exactly but not many.)
If you take the values and multiply them by 10^6, round() that, and divide by 10^6, the result will be a matrix that will have the closest possible binary floating point numbers to the ones with 6 digits after the decimal point.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by