memory problem

The matlab code below was used to search the contents of File2 with the contents of file1, and with the example output below. However, when large files are involved, the output is reduced.
File1:
M1U152S44906X14127_xu
M1U7S112336U117688_xu
File2 (tab delimited):
T1X19S17508N179711_xu AAU_779
M1U152S44906X14127_xu xcup
M1U7S112336U117688_xu mmna
Expected output:
M1U152S44906X14127_xu xcup
M1U7S112336U117688_xu mmna
Code:
clear all;
clc;
%Open flux file for reading
fid = fopen('File2.txt')
if fid ==-1
disp('Reaction_Flux file open not successful')
else
% Read characters and numbers into separate elements
% in a cell array
rxn_flux = [];
A = [];
B = [];
C = [];
rxn_flux = textscan(fid,'%d %s %s');
A = rxn_flux{1};
B = rxn_flux{2};
C = rxn_flux{3};
len1 = length(B);
closeresult1 = fclose(fid);
if closeresult1 == 0
disp('Reaction_Flux file close successful')
else
disp('Reaction_Flux file close not successful')
end
end
%Open reaction file for reading
fid = fopen('File1.txt')
if fid ==-1
disp('Flux file open not successful')
else
% Read characters and numbers into separate elements
% in a cell array
[rxn] = textread('File1.txt','%s');
%rxn = textscan(fid,'%s');
D = rxn;
len2 = length(D);
closeresult2 = fclose(fid);
if closeresult2 == 0
disp('Reaction file close successful')
else
disp('Reaction file close not successful')
end
end
%Open output file for writing results
fid = fopen('OutputFile.txt','w');
fprintf(fid,'The following were found in File 1:\n')
RXNFLUX = false(size(B));
for i = 1:len2
RXNFLUX = RXNFLUX | strcmpi(D{i},B);
end
if any(RXNFLUX)
iLines = [];
iLines = find(RXNFLUX);
for i=1:size(iLines)
fprintf(fid,'%s\t, %s\n',B{iLines(i)}, C{iLines(i)});
% B{iLines(i)} and C{iLines(i)}
%fprintf(fid,'%s\t, %s\n', B, C);
%fprintf(fid, '%s\n', B{:});
%dlmwrite('output.txt',B(iLines(i)),'\n');
end
else
disp('rxn not found')
end
fclose(fid);
I will be happy to get some help to resolve the problem.
Thanks

댓글 수: 2

per isakson
per isakson 2012년 6월 6일
Does the full content of File1 and File2 fit i memory at the same time? How large are they?
Jason Ross
Jason Ross 2012년 6월 6일
Can you add:
Operating system
32 bit vs. 64 bit
Amount of RAM in your system
Version of MATLAB
Amount of free memory at start (e.g. run the "memory" command)

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2012년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by