필터 지우기
필터 지우기

When I convert my data which is available in structure format to table it accuracy decreases

조회 수: 4 (최근 30일)
When I convert my data which is available in structure format to table which I requre for further plotting the values like 0.7 or 0.5 changes to 1 and 0.
I am use the command
struct2table(name);
for example
from
0.505829210007949
0.549192911465458
0.539702546882381
0.529415778849225
31.7804971641414
0.459445413396004
1.18079450595063
1.21475111433387
to
0
0
0
0
1
  댓글 수: 2
Ive J
Ive J 2020년 12월 16일
Please provide your script along with the result you get. I cannot reproduce your output solely based on your question.
myStruct.vals = [0.505829210007949
0.549192911465458
0.539702546882381
0.529415778849225
31.7804971641414
0.459445413396004
1.18079450595063
1.21475111433387];
struct2table(myStruct)
ans =
8×1 table
vals
_______
0.50583
0.54919
0.5397
0.52942
31.78
0.45945
1.1808
1.2148
dpb
dpb 2020년 12월 16일
No, you did something else either in the display formatting or converting to a logical array or somesuch. MATLAB will retain full precision of the data in the conversion internally; there may be some slight loss of precision if you were to write to a file with high-level routines but it would still have 5-6 decimal digits of precision at worst.
You'll have to post a complete working example that reproduces the problem for folks to be able to diagnose just exactly what you did to get the symptom, but it is operator error, not MATLAB bug.

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

답변 (1개)

Walter Roberson
Walter Roberson 2020년 12월 16일
편집: Walter Roberson 2020년 12월 16일
Your table contains an integer datatype. When you combine numeric datatypes in an array, the result is converted to the most restrictive datatype
val = [int8(-3) int16(555) pi]
val = 1×3
-3 127 3
class(val)
ans = 'int8'
What shows up for
unique( varfun(@class, T, 'output', 'cell') )

카테고리

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