Reading a hex table with some undefined values
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Robert
el 9 de Ag. de 2020
Comentada: Walter Roberson
el 10 de Ag. de 2020
I have a text table with hex values. Some of the values are of the form 0xXXXX. I'd like to read in the entire table as doubles with the 0xXXXX entries read as NaN. How do I do that?
3 comentarios
Respuesta aceptada
Robert
el 10 de Ag. de 2020
1 comentario
Walter Roberson
el 10 de Ag. de 2020
If it was the "convert to double" that is the reason not to use the code I posted, then after my code use
varnames = data.Properties.VariableNames;
data = varfun(@double, data, ''); %changes variable names
data.Properties.VariableName = varnames;
Más respuestas (1)
Walter Roberson
el 10 de Ag. de 2020
filename = 'hex.txt';
missingindication = {'0xXXXXX'};
data = readtable(filename, 'treatasmissing', missingindication, 'readvariable',false, 'delimiter', ' ', 'multi', true);
This code will work for up to 16 hex digits; any column that has a value 2^32 or larger will be returned as uint64 .
If the missing data indicator itself can have different numbers of X characters, then you can expand the cell array, such as
missingindication = arrayfun(@(c) ['0x', repmat('X', 1, c)], 1:32, 'uniform', 0);
0 comentarios
Ver también
Categorías
Más información sobre Contour Plots 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!