Running two programs at once.
Running two programs at once.
(OP)
I have created a Fig, now im reading into a variable 12,000,000 points from a file. Using Textread. Now this takes me 10 min to do, I would like to have some sort of progress bar, or simply show that the computer has not frozen without lossing speed.
I was thinking of creating an houre glass type function, or
printing out '|'->'/'->'-'->'\'->'|' to show something is going on.
How do I run this program and read from the file at the same time.
fscanf take 6 time longer.
I was thinking of creating an houre glass type function, or
printing out '|'->'/'->'-'->'\'->'|' to show something is going on.
How do I run this program and read from the file at the same time.
fscanf take 6 time longer.





RE: Running two programs at once.
This doesn't run two programs at once, but it will read a text file and store it as a mat file and then read the mat file if the mat file exists and is newer than the text file. So this code helps if you have to read the same text file over and over, but you might change it occansionaly.
function file=readfile(fname)
% Read the text file if it is new that a saved mat file
mname = [fname '.mat'];
ddmat=dir(mname);
ddout=dir(fname);
% Determine the second when the files were created
if (isempty(ddmat))
sec_mat=0;
else
[Y,M,D,H,MI,S] = datevec(ddmat.date); Day=datenum(ddmat.date); sec_mat=((Day*24+H)*60+MI)*60+S;
end
[Y,M,D,H,MI,S] = datevec(ddout.date); Day=datenum(ddout.date); sec_out=((Day*24+H)*60+MI)*60+S;
% read text if out is newer than mat (or mat is zero)
if (sec_out>sec_mat | sec_mat==0)
file = char(textread(fname,'%s','delimiter','\n','whitespace',''));
save(mname,'file');
else
file=load(mname,'file');
file=file.file;
end