フィルターのクリア

How to import a text file into matlab

1 回表示 (過去 30 日間)
mohamed Faraj
mohamed Faraj 2018 年 10 月 7 日
コメント済み: jonas 2018 年 10 月 8 日
I have a text file "attached" and I would like to import it to matlab. The file ia arranged into 3 columns and each of three columns has 4 sub-columns. I want to import these data to an array M with size(M)=[80,3,4], e.g., if the first row of the text file is {1,2,3,4} {5,6,7,8} {9,10,11,12}, then M(1,1:3,1)={1,5,9},M(1,1:3,2)={2,6,10}...etc

採用された回答

jonas
jonas 2018 年 10 月 7 日
編集済み: jonas 2018 年 10 月 7 日
fid = fopen('t.txt');
out=textscan(fid,repmat('%f',[1,12]),'delimiter',{'\t',',','{','}'},'MultipleDelimsAsOne',1)
fclose(fid)
out=cell2mat(out);
out=reshape(out,[80,4,3])
or perhaps you need to add this line to get the right structure
out = permute(out,[1 3 2]);
  2 件のコメント
mohamed Faraj
mohamed Faraj 2018 年 10 月 8 日
Thank you Jonas. It worked well
jonas
jonas 2018 年 10 月 8 日
My pleasure! Please formally accept the answer!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by