addpath('C:\Documents and Settings\Steve\My Documents\Research\matlab') addpath('C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqUtil') for i=1:1 for j=1:1 for k=1:1 for m=1:1 folder = (['C:\Documents and Settings\Steve\My Documents\Research\optNew\linlsqOpt\tomo\phantrad' num2str(i-1) ... '\boostrad' num2str(j-1) '\contrast' num2str(k-1) '\a' num2str(m-1) '\input']); cd(folder) presc = open_presc(['TumorMinusBoostDosePlus.bin']); Nstep = 1; dpresc = (max(presc.non_zero_values)-min(presc.non_zero_values))./Nstep; minpresc = min(presc.non_zero_values); ind = {}; for n=1:Nstep; ind{n} = find(presc.non_zero_values >= (n-1)*dpresc + minpresc ... & presc.non_zero_values < n*dpresc + minpresc); presc.non_zero_values(ind{n}) = mean(presc.non_zero_values(ind{n})); end fid = fopen(['TumorMinusBoostDosePlus.bin'],'wb'); fwrite(fid,presc.x_count,'int'); fwrite(fid,presc.y_count,'int'); fwrite(fid,presc.z_count,'int'); fwrite(fid,presc.Nind,'int32'); fwrite(fid,presc.non_zero_indices,'int32'); fwrite(fid,presc.non_zero_values,'single'); fclose(fid); fid = fopen(['TumorMinusBoostDoseMinus.bin'],'wb'); fwrite(fid,presc.x_count,'int'); fwrite(fid,presc.y_count,'int'); fwrite(fid,presc.z_count,'int'); fwrite(fid,presc.Nind,'int32'); fwrite(fid,presc.non_zero_indices,'int32'); fwrite(fid,presc.non_zero_values,'single'); fclose(fid); end end end end fprintf(['Prescription discretized into ' num2str(Nstep) ' steps successfully.\n'])