same code but with different behavior each time
Show older comments
I have file with large length (2444546), so I segmented it into 2 parts,each part with length(1222273).With total length i got out of memory and run this code:
fid = fopen('d:\matlab\r2011a\bin\flixsterdata\finalflix0.txt','r');
c = textscan(fid,'(%d,%d)\t%d')
c1=c{1};c2=c{2};c3=c{3};
LL=length(c1)
L=round(LL/2)
w=double(c1(1:L)); w1=double(c2(1:L)); w2=double(c3(1:L));
flix0=accumarray([w,w1],w2);
[m,n]=size(flix00);
f=fopen('flix00.txt','w');
for i=1:m
for j=1:n
fprintf(f,'%d',flix00(i,j));
end
end
fclose all
I ran this code for the first part, and no problem
But when I ran the same code for the second part , where start from 1222274(code below), I got this error:
??? Error using ==> accumarray
Out of memory. Type HELP MEMORY for your
options.
Error in ==> g at 8 flix0=accumarray([w,w1],w2);
the same code and for the same size of file , but it's behavior is different
fid = fopen('d:\matlab\r2011a\bin\flixsterdata\finalflix0.txt','r');
c = textscan(fid,'(%d,%d)\t%d','headerLines', 1222274); c1=c{1};
c2=c{2};c3=c{3}; LL=length(c1) L=round(LL/2) w=double(c1(1:L));
w1=double(c2(1:L)); w2=double(c3(1:L));
flix0=accumarray([w,w1],w2);
1 Comment
Jan
on 3 Dec 2011
Please, huda, format your code properly to make the reading easier.
Answers (1)
Walter Roberson
on 3 Dec 2011
0 votes
Like I told you before, use %f format in doing your reads, and skip the double() step. You should be avoiding making copies of your input.
Categories
Find more on Whos 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!