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

20 ビュー (過去 30 日間)
Danupon Subanapong
Danupon Subanapong 2018 年 11 月 14 日
コメント済み: madhan ravi 2018 年 11 月 14 日
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.

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 14 日
編集済み: madhan ravi 2018 年 11 月 14 日
fid=fopen('Example_of_input3.txt');
f=textscan(fid,'%s', 'delimiter','\n');
fclose(fid);
celldisp(f)
  4 件のコメント
Danupon Subanapong
Danupon Subanapong 2018 年 11 月 14 日
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?
A=zeros(12000,5);
for i=4:end
A(i,:)=str2num(string(f{1}{i})
end
madhan ravi
madhan ravi 2018 年 11 月 14 日
Anytime :) , see my previous comment just use indexing loop is not needed , search indexing cell array in internet and read slowly you will understand

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by