import data function breaks at NaN or not a number
Show older comments
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
Accepted Answer
More Answers (1)
Walter Roberson
on 10 Dec 2015
0 votes
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 Comments
Sanwal Yousaf
on 11 Dec 2015
Edited: Sanwal Yousaf
on 11 Dec 2015
Walter Roberson
on 11 Dec 2015
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
on 13 Dec 2015
Walter Roberson
on 13 Dec 2015
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
on 13 Dec 2015
There was originally an excel file that would have been imported without difficulty; that was replaced with the tricky text file.
Sanwal Yousaf
on 17 Dec 2015
Categories
Find more on Spreadsheets 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!