フィルターのクリア

Read data from file

2 ビュー (過去 30 日間)
Nidhi SRIVASTAVA
Nidhi SRIVASTAVA 2017 年 7 月 3 日
編集済み: per isakson 2017 年 7 月 3 日
I have a huge file with data format:
(2,4) (5,6)
(34,26) (22,78)
(18,76) (33,50) etc.
I want to create 4 matrix with data as(2,34,18) ; (4,26,76); (5,22,33) and (6,78,50). I used textscan to read the data but couldn't use it aptly. If anybody could guide me with it, it will be very helpful.
  2 件のコメント
Image Analyst
Image Analyst 2017 年 7 月 3 日
Make it easy for people to help you by attaching the file. We don't need all 42 terabytes of it, just a few lines.
KSSV
KSSV 2017 年 7 月 3 日

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

採用された回答

per isakson
per isakson 2017 年 7 月 3 日
編集済み: per isakson 2017 年 7 月 3 日
Two variants
fid = fopen( 'cssm.txt' );
cac = textscan( fid, '(%d,%d) (%d,%d)', 'Whitespace','' ...
, 'Delimiter',' ', 'CollectOutput',true );
fclose( fid );
num1 = cac{1};
fid = fopen( 'cssm.txt' );
cac = textscan( fid, '%d%d%d%d', 'MultipleDelimsAsOne',true ...
, 'Delimiter','(),', 'CollectOutput',true );
fclose( fid );
num2 = cac{1};
m1 = permute( num2(:,1), [2,1] );
m2 = permute( num2(:,2), [2,1] );
m3 = permute( num2(:,3), [2,1] );
m4 = permute( num2(:,4), [2,1] );
Inspect the result
>> all(all(num1==num2))
ans =
1
>> num2
num2 =
2 4 5 6
34 26 22 78
18 76 33 50
>>
Do you really want m1,m2,m3 and m4?

その他の回答 (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