Problems with empty cell in a large matrix
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (2)
Read about readtable. It will insert NaN's where ver values are missing.
T = readtable('sample.txt') ;
3 commentaires
madhan ravi
le 20 Mar 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
le 28 Août 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
le 28 Août 2019
Thank you Peter for the response :)
Poulomi Ganguli
le 20 Mar 2019
0 votes
1 commentaire
madhan ravi
le 20 Mar 2019
Probably you would have to wait for others to shed some light here.
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!