How to load portions of .dat file

5 Ansichten (letzte 30 Tage)
Raffaella Assogna
Raffaella Assogna am 5 Okt. 2022
Kommentiert: Walter Roberson am 6 Okt. 2022
Hello everyone,
I'm trying to load a large .dat file. It is made by a 3x15000000 matrix. So I want to load only a portion of it time, like 3x30000 at one time, analyze that portion and then load another 3x30000 portion. Can someone help me? Thank you
  6 Kommentare
Chunru
Chunru am 6 Okt. 2022
doc fopen
doc fread
doc fseek
Raffaella Assogna
Raffaella Assogna am 6 Okt. 2022
Thank you so much, fseek was the function I was searching for

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 5 Okt. 2022
[fid, msg] = fopen(FileName, 'r', 'b');
assert(fid > 0, msg);
while true
data = fread(fid, [3, 30000], 'uint32');
if numel(data) < 3*30000
break;
end
... process the block of data here
end
  7 Kommentare
Walter Roberson
Walter Roberson am 6 Okt. 2022
65175552/4/3
ans = 5431296
so your file has room for about 18 times as much data as would be needed for [3, 30000], and the data = fread(fid, [3, 30000], 'uint32'); should have succeeded unless you had already read a portion of the file (or had used fseek to get to near the end.)
Walter Roberson
Walter Roberson am 6 Okt. 2022
If you have a structured binary file, consider using memmapfile()

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by