Reading from a .txt file

2 ビュー (過去 30 日間)
Peter
Peter 2014 年 7 月 28 日
編集済み: Cedric 2014 年 7 月 28 日
Hello,
I have a .txt file with 100 matrices (3*4) each followed by a number. I want to read matrices into a 3D array and numbers into 1D array? How do I do it?
Data looks like:
1 2 3 4
1 2 3 4
1 2 3 4
5
4 5 6 7
4 5 6 7
4 5 6 7
7
3 5 7 3
3 5 7 3
3 5 7 3
3 5 7 3
3
...

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 28 日
d=importdata('file.txt');
A=d;
b=A(4:4:end,1);
A(4:4:end,:)=[];
A=reshape(A,3,4,[]);
disp(b)
disp(A)
  1 件のコメント
Cedric
Cedric 2014 年 7 月 28 日
編集済み: Cedric 2014 年 7 月 28 日
+1 Damn' ;-), I'll have to start using this IMPORTDATA!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by