When I convert my data which is available in structure format to table it accuracy decreases
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Ive J
el 16 de Dic. de 2020
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
el 16 de Dic. de 2020
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.
Respuestas (1)
Walter Roberson
el 16 de Dic. de 2020
Editada: Walter Roberson
el 16 de Dic. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!