Problems with empty cell in a large matrix
Show older comments
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?
Accepted Answer
More Answers (2)
Read about readtable. It will insert NaN's where ver values are missing.
T = readtable('sample.txt') ;
3 Comments
madhan ravi
on 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
on 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
on 28 Aug 2019
Thank you Peter for the response :)
Poulomi Ganguli
on 20 Mar 2019
0 votes
1 Comment
madhan ravi
on 20 Mar 2019
Probably you would have to wait for others to shed some light here.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!