Problems with empty cell in a large matrix
Mostrar comentarios más antiguos
Hello:
I have a large matrix of 102730 rows in the form of text file (sample text file is attached) with some header files in it. The first column show year, the next the month, followed by the day, and value1, value2 and value 3. Some of the cells are missing/empty. I want to fill these empty cells with NaN, so that they don't interefere with the next value. I am also attaching the text files of sample input (sample.txt) and desired output (Output.txt) for your reference.
Could anyone please let me know how to retrieve data?
Respuesta aceptada
Más respuestas (2)
Read about readtable. It will insert NaN's where ver values are missing.
T = readtable('sample.txt') ;
3 comentarios
madhan ravi
el 20 de Mzo. de 2019
Beware, the value next to 41.2 should be NaN whereas this answer gives 16. I have no idea why that’s happening.
Peter Perkins
el 28 de Ag. de 2019
That happens because readtable treats the file as space-delimited, when in fact it is fixed-width format. See my response below.
madhan ravi
el 28 de Ag. de 2019
Thank you Peter for the response :)
Poulomi Ganguli
el 20 de Mzo. de 2019
0 votos
1 comentario
madhan ravi
el 20 de Mzo. de 2019
Probably you would have to wait for others to shed some light here.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!