import data function breaks at NaN or not a number
이전 댓글 표시
I am trying to use import_data function to import dataset from the data file. This data set is generated from iterations of an experiment based upon the response from the subjects. This kind of data set is bound to end up have a Not a Number or a missing response and not extract anything after that. I am trying to figure out a way to import data and not have the function break at Not A Number or a missing response. The function extracts the row before the Not a Number and not after the NaN row. I am attaching the data file that i am interested in. Any help would be greatly appreciated.
P.S. The experiment running the experiment generates a .txt file everytime and i am not allowed to mess with that program.I am including the .txt file as well
채택된 답변
추가 답변 (1개)
Walter Roberson
2015년 12월 10일
0 개 추천
I have no problem with that file even on a Mac (which cannot use Excel to open the file.)
[num, txt, raw] = xlsread('time-react.xlsx');
The num array has NaN for the missing or string responses. txt or raw can be used to get to the corresponding strings.
댓글 수: 7
Sanwal Yousaf
2015년 12월 11일
편집: Sanwal Yousaf
2015년 12월 11일
Walter Roberson
2015년 12월 11일
import_data() is completely unsuited for importing files with multiple structures. If you are required to use import_data() for that USE_THIS.txt file then there is no way you are going to be able to do it.
Sanwal Yousaf
2015년 12월 13일
Walter Roberson
2015년 12월 13일
My suggestion would be to report back to whoever imposed the restriction of using import_data() to tell them that it is not at all suitable for importing files that look anything like that.
If it was you who choose to use import_data() then "Don't do that!". Guillaume made a start at code that could be used.
I assume the question has been edited at some point since I don't see where the OP says he has to use import_data, nor do I see the excel file you reference in your initial answer.
Certainly, there's no single one-liner operation that can import the file neatly.
Walter Roberson
2015년 12월 13일
There was originally an excel file that would have been imported without difficulty; that was replaced with the tricky text file.
Sanwal Yousaf
2015년 12월 17일
카테고리
도움말 센터 및 File Exchange에서 JSON Format에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!