Problems with empty cell in a large matrix
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (2)
Read about readtable. It will insert NaN's where ver values are missing.
T = readtable('sample.txt') ;
3 Kommentare
madhan ravi
am 20 Mär. 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
am 28 Aug. 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
am 28 Aug. 2019
Thank you Peter for the response :)
Poulomi Ganguli
am 20 Mär. 2019
0 Stimmen
1 Kommentar
madhan ravi
am 20 Mär. 2019
Probably you would have to wait for others to shed some light here.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!