need shrter code

조회 수: 2 (최근 30일)
huda nawaf
huda nawaf 2012년 5월 6일
hi,
can anybody make these code shorter and faster?
Nofusers=17856;
k1 = 1;
f1 = fopen('d:\matlab11\bin\flixster_time\ratings_tf\len_flix1.txt');
c = fscanf(f1,'%d');
fclose(f1)
ini = 1;
f = fopen('d:\matlab11\bin\flixster_time\ratings_tf\flix_fin.txt');
cod = fscanf(f,'%d');
for i = 1:17856
k = 1;
for j = ini:c(i)+ini-1
celcod{i}(k) = cod(j);
k = k+1;
end;
ini = ini + c(i);
end
thanks
  댓글 수: 1
Jan
Jan 2012년 5월 6일
This is your 109'th question in this forum. I expect that you know how to format the code.
Do you have a good reason not to care about the readability of your question?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2012년 5월 6일
...
celcod = cell(1, 17856); % Pre-allocate!
ini = 1;
for i = 1:17856
celcod{i} = cod(ini:c(i)+ini-1);
ini = ini + c(i);
end
  댓글 수: 1
huda nawaf
huda nawaf 2012년 5월 7일
thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by