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!