필터 지우기
필터 지우기

load very large data file in 32bit matlab 2013 and windows 7 32bit

조회 수: 3 (최근 30일)
Safiya
Safiya 2015년 12월 28일
답변: Walter Roberson 2015년 12월 28일
Hi,
i have a very large data file (.txt), 15 coloumns and several rows. (600MB). figures are plotted successfully but have to enlarge the cache memory. is there any way to transform this file to other format so that it can be read quickly and to reduce size . e.g .mat etc,
thanks

답변 (1개)

Walter Roberson
Walter Roberson 2015년 12월 28일
Generally speaking, you can use
fid_in = fopen('YourInput.txt', 'rt');
fid_out = fopen('BinaryVersionOfTxt.dat', 'w'); %no 't'
while true
inputline = fgetl(fid_in);
if ~ischar(input_line); break; end %end of file
input_num = sscanf(inputline, '%f');
fwrite(fid_out, input_num(:), 'double');
end
fclose(fid_in);
fclose(fid_out);
BinaryVersionOfTxt.dat will now be a binary data file of doubles, with the values saved reading across in row order from the input file. This code will handle any number of inputs on each line and does not put in any kind of end-of-row marker, so be careful about interpreting the file.
If the values are integer then you can reduce storage by changing the program slightly.
You would do the above conversion once and then you can read the binary file any number of times.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by