我有一个将近 150 MB 到 500 MB 的大文本文件,这个文件包含 20 行 lacs ......
文件内容是这样的......
USDINR12AUGFUT 1 1343791803 579782 2012-08-01 09:00:03 BID 55.5725 200
USDINR12AUGFUT 2 1343791803 594246 2012-08-01 09:00:03 BID 55.9650 150
USDINR12AUGFUT 3 1343791803 594570 2012-08-01 09:00:03 ASK 56.0700 100
USDINR12AUGFUT 4 1343791803 946831 2012-08-01 09:00:03 ASK 56.0450 500
USDINR12AUGFUT 5 1343791804 16514 2012-08-01 09:00:04 TRADE 55.9650 5 55965.00 5
USDINR12AUGFUT 6 1343791804 19401 2012-08-01 09:00:04 BID 55.9800 14
USDINR12AUGFUT 7 1343791804 32311 2012-08-01 09:00:04 BID 56.0000 100
USDINR12AUGFUT 8 1343791804 33292 2012-08-01 09:00:04 ASK 56.0400 150
USDINR12AUGFUT 9 1343791804 34695 2012-08-01 09:00:04 TRADE 56.0000 1 55970.83 6
USDINR12AUGFUT 10 1343791804 35599 2012-08-01 09:00:04 TRADE 56.0000 1 55975.00 7
USDINR12AUGFUT 11 1343791804 36626 2012-08-01 09:00:04 TRADE 56.0000 1 55978.12 8
USDINR12AUGFUT 12 1343791804 53676 2012-08-01 09:00:04 TRADE 56.0000 60 55997.43 68
USDINR12AUGFUT 13 1343791804 57434 2012-08-01 09:00:04 TRADE 56.0000 25 55998.12 93
USDINR12AUGFUT 14 1343791804 57967 2012-08-01 09:00:04 TRADE 56.0000 1 55998.14 94
USDINR12AUGFUT 15 1343791804 60474 2012-08-01 09:00:04 TRADE 56.0000 1 55998.16 95
USDINR12AUGFUT 16 1343791804 60988 2012-08-01 09:00:04 TRADE 56.0000 1 55998.18 96
USDINR12AUGFUT 17 1343791804 61232 2012-08-01 09:00:04 TRADE 56.0000 1 55998.20 97
USDINR12AUGFUT 18 1343791804 61974 2012-08-01 09:00:04 TRADE 56.0000 1 55998.21 98
USDINR12AUGFUT 19 1343791804 62449 2012-08-01 09:00:04 TRADE 56.0000 1 55998.23 99
我的问题是我想使用这个文件在 MATLAB 上做一些回测,所以我必须导入这个文件。但是每当我使用fopen
并且textscan
MATLAB抛出一个错误说......
??? Error using ==> textscan
Out of memory. Type HELP MEMORY for your options.
但是当我使用 20-50 MB 文件时,它运行良好。
如何克服这一点?帮帮我...
我的代码:
% file_path = 'E:\volume\august\AUG03.MCX';
file_path = 'D:\home\flexsys\pavan\usdinr_t\USDINR12AUGFUT.MCX';
fid = fopen(file_path);
C = textscan(fid,'%s %d %d %d %s %s %s %f %d %f %d');
n = length(C{1});
for i = 1 : n
raw_data.symbol(i) = C{1}(i);
raw_data.trade_no(i) = C{2}(i);
raw_data.utc_sec(i) = C{3}(i);
raw_data.utc_nano(i) = C{4}(i);
raw_data.date(i) = C{5}(i);
raw_data.time(i) = C{6}(i);
raw_data.trade_type(i) = C{7}(i);
raw_data.ltp(i) = C{8}(i);
raw_data.ltq(i) = C{9}(i);
raw_data.vwap(i) = C{10}(i);
raw_data.volume(i) = C{11}(i);
% % % some back testing here.
end
我已将所有数据存储在C
变量中并且出现错误