MATLAB/ stop working /RAM

1 view (last 30 days)
Aisha
Aisha on 14 Jun 2014
Answered: Aisha on 21 Jun 2014
Hi, please can you help me in the following issue,
I have a script code in Matlab, that consist from three loops. From each combination , a configuration file produced and called a simulator to run it, then a result file produced, and copy it to another directory, then take some info from the result file and write it on the main text file (in append mode), i must have 3600 experiment, but matlab exist without any error after 490 experiment, my computer 4 GB, i7.
Here is my code, i tried to make my steps as comments..
% i have two main files: main config file and main app file..
for k=1:30
for r= 1:6
% here i copy the main app file into another file
% now,i want to edit the new app file, using the following
% method:
% copy the content of the app file into AppFileData cell
fid = fopen(AppFile,'r');
i = 1;
tline = fgetl(fid);
AppFileData{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
AppFileData{i} = tline;
end
fclose(fid);
% edit a specific line ...
% Write AppFileData cell into the app file
fid = fopen(AppFile, 'w');
for i = 1:numel(AppFileData)
if AppFileData{i+1} == -1
fprintf(fid,'%s', AppFileData{i});
break
else
fprintf(fid,'%s\n', AppFileData{i});
end
end
clearvars('AppFileData');
% copy the app file to the directory you specified ...
for s=1:30
% here i copy the main config file into another file
% now,i want to edit the new config file, using the following
% method:
% copy the conent of the config file into cell A
fid = fopen(ConfigFile,'r');
i = 1;
tline = fgetl(fid);
A{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
A{i} = tline;
end
fclose(fid);
% Change a specific line ..
% Write cell A into the config file
fid = fopen(ConfigFile, 'w');
for i = 1:numel(A)
if A{i+1} == -1
fprintf(fid,'%s', A{i});
break
else
fprintf(fid,'%s\n', A{i});
end
end
clearvars('A');
% copy the config file to the directory you specified ...
% call the simulator to run the scenario with the new app file and new config file specifed ...
% copy the result file to the directory you specified ...
%%copy the conent of the stat file (created from the simultor) into cell A
fid = fopen('qualnet.stat','r');
i = 1;
tline = fgetl(fid);
A{i} = tline;
while ischar(tline)
i = i+1;
tline = fgetl(fid);
A{i} = tline;
end
fclose(fid);
% find the line number of the line contain the information i want in the stat file ..
% write the information i want intothe main result text file
fid = fopen( 'ResultText.txt', 'a');
myformat = '%s %f %d %d %f \n';
fprintf(fid, myformat,StatFile,RssiAlphaValues(k),setupTrials(r),seeds(s),CurrentMeanError);
fclose(fid);
end
end
end
Thanks,

Answers (2)

Image Analyst
Image Analyst on 14 Jun 2014
Set a breakpoint at the "break" statements and see if it ever stops there. If you don't know how to do that, see this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/

Aisha
Aisha on 21 Jun 2014
Thanks, the problem was missing fclose !

Tags

Products

Community Treasure Hunt

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

Start Hunting!