When I convert my data which is available in structure format to table it accuracy decreases
1 回表示 (過去 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
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
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
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]
class(val)
What shows up for
unique( varfun(@class, T, 'output', 'cell') )
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!