MATLAB Answers


How to import data with string, missing data,and numeric values?

Asked by Danupon Subanapong on 14 Nov 2018
Latest activity Commented on by madhan ravi
on 14 Nov 2018
Hi!! I would like to ask for your help. I have to a number of import text data. Inside these text files, there are strings, numeric values, and missing data. I have been seeking for how to import these files. I tried importdata, but it only imports data from row no.1 to the missing data row. I will attach the example of input file as well. Please check it.


Sign in to comment.




1 Answer

Answer by madhan ravi
on 14 Nov 2018
Edited by madhan ravi
on 14 Nov 2018
 Accepted Answer

f=textscan(fid,'%s', 'delimiter','\n');


Show 1 older comment
f{1}{1:3} %others
f{1}{4:end} %numeric
Anytime :) make sure to accept the answer if you got the answer to your question
Thank you so much. Your answer is very helpful. I have one last question. I have been trying to convert the character array f{1}{4:end} to numeric array. I try to use for loop as shown below. But it takes very long time to process. Can you please suggest some alternative for faster solution?
for i=4:end
Anytime :) , see my previous comment just use indexing loop is not needed , search indexing cell array in internet and read slowly you will understand

Sign in to comment.