Problems with empty cell in a large matrix
이전 댓글 표시
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?
채택된 답변
추가 답변 (2개)
Read about readtable. It will insert NaN's where ver values are missing.
T = readtable('sample.txt') ;
댓글 수: 3
madhan ravi
2019년 3월 20일
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
2019년 8월 28일
That happens because readtable treats the file as space-delimited, when in fact it is fixed-width format. See my response below.
madhan ravi
2019년 8월 28일
Thank you Peter for the response :)
Poulomi Ganguli
2019년 3월 20일
0 개 추천
댓글 수: 1
madhan ravi
2019년 3월 20일
Probably you would have to wait for others to shed some light here.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!