NEED HELP FAST! I have several problem about ASCII file.
Show older comments
So, I have a ASCII data file with unknown number (NaN). My teacher want me to change NaN into -99.9999. But when I tried so many times, the undefined variable error is appear. WHAT SHOULD I DO? Pls I appreciate if anyone can help :))
1 Comment
Walter Roberson
on 20 Jul 2018
Please do not close questions that have an answer.
Answers (1)
Image Analyst
on 18 Jul 2018
What did you try? Did you try the obvious
data(isnan(data)) = -99.9999;
?? What error message did you get?
6 Comments
Image Analyst
on 18 Jul 2018
By the way, that's an Excel workbook file, not an ASCII text file.
della tan
on 18 Jul 2018
Edited: Walter Roberson
on 18 Jul 2018
della tan
on 18 Jul 2018
Image Analyst
on 18 Jul 2018
column E is considered text data by Excel since there is no equals sign there. To get everything, try this:
[numbers, strings, raw] = xlsread('COBA.xlsx');
numbers(isnan(numbers)) = -99.9999;
strings will be a cell array of your strings in column e. If you want to parse the strings into numbers, use textscan(), or sscanf(), or strsplit() with str2double().
della tan
on 18 Jul 2018
Walter Roberson
on 18 Jul 2018
It would be easier to go back to the original text data and import that properly, than to continue working with this badly input .xlsx
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!