load text file

5 ビュー (過去 30 日間)
Baba
Baba 2011 年 11 月 3 日
I have a text file that is too large to load with the file=load'file.txt' command. it's basically many rows of numbers where each column separated by a space.
1 2 3 1 4 2 1 56 2....
1 4 1 56 2 3 4 2 3 ....
....
Each row contains data from several channels. So for instance data from channel 1 would be 1 2 3 1 4 1, first 3 numbers of every line:
What I'd like to do is to filter and downsample data from each channel.
so basically I'm wondering what command is best to use to pick out specific parts of text file without using "load"
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 3 日
How large is the file? How many rows and columns?

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

採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 3 日
samplesperchan = 3;
channelnum = 6; %for example
lineformat = [repmat('%*f', 1, samplesperchan*(channelnum-1)), repmat('%f',1,samplesperchan), '%*[^\n]'];
result = textscan(fid, lineformat, 'CollectOutput', 1);
  8 件のコメント
Walter Roberson
Walter Roberson 2011 年 11 月 4 日
It sounds as if you might need to use 'bufsize' with a large number -- as large as your longest line.

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

その他の回答 (1 件)

Ora Zyto
Ora Zyto 2011 年 11 月 3 日
Depending on the format of your data, TEXTSCAN may be a good option. This is a very flexible function, where you can specify the format of your data programatically.
You could read lines one by one and parse the data directly. If your data is rectangular, you could also try reading it all at once.
Ora
  1 件のコメント
Baba
Baba 2011 年 11 月 3 日
Thank you

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

カテゴリ

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by