#system("head -1 cements.txt");
#system(sprintf("head -1 cements.txt");
#fclose(3);fopen("cements.txt");comlin=fscanf(3,"%1c")
#fclose(3);fopen("cements.txt");comlin=fgets(3)

f=fopen("cements.txt");
cementline1=fgets(f);
c=cementline1;
d=c(1:length(c)-1); % get rid of carriage return
% e.g. 00260.jpg 1 1 1
sp=" ";
comm1=["cementinit" sp "     " d sp "-o tot.plm"];       % e.g. cementinit 00260.jpg 1 1 1 -o tot.plm
disp(comm1)
system(comm1)
comm1out="plm2pnm tot.plm -o t001.jpg";
disp(comm1out)
system(comm1out) % generate first frame

for k = 2:231

 %k=2; % second frame of output sequence
 cementlinek=fgets(f);
 chomped=cementlinek(1:length(cementlinek)-1);
 commki=["cementi "   "tot.plm "    chomped];             % e.g. cementi tot.plm 00261.jpg 1 1 1
 disp(commki)
 system(commki)
 commkout=["plm2pnm tot.plm -o " sprintf("t%03d.jpg",k)]; % e.g. plm2pnm tot.plm -o t002.jpg
 disp(commkout)
 system(commkout)
 
 %commkplm=["plm2pnm tot.plm -o " sprintf("t%03d.jpg",k)]; % e.g. plm2pnm tot.plm -o t002.jpg
 %disp(commkplm)
 %system(commkplm)

end%for k

