%This script file is called by the program before cpdf.m if the user has .dat files that need to %be converted to .cp files before analysis is done. %Get some parameters from the screen if strcmp(get(o3000,'Checked'),'on'), NPTS = 3000; else NPTS = 6000; end LAGMAX = 1000; datafilesnum = str2num(get(filenum2,'String')); datafiles = get(filedata2,'String'); set(h,'Pointer','watch'); datapatho = get(filepatho2,'String'); datapathc = get(filepathc2, 'String'); X = zeros(1,LAGMAX+2); Y = zeros(1,LAGMAX+2); for i=1:datafilesnum, %Loop through the data files: load, convert from .dat to .cp data = strtok(datafiles); fid = fopen([datapatho,data,'.dat'],'rt'); gain = fscanf(fid,'%d',1); [temp1,mysize] = fscanf(fid,'%d',[3000,2]); fclose(fid); temp2 = fixit(temp1); if mysize ~= 6000, error('30 seconds worth of data was not scanned'); end %convert .dat files to .cp files and save (the next few lines are %taken from cpkist4.c to do the conversion from .dat files to .cp files) if gain == 3, softgain = 8; elseif gain == 2, softgain = 4; elseif gain == 1, softgain = 2; else softgain = 1; end k = 50*20/4096.0/softgain; temp = temp2*k; fid = fopen([datapathc,data,'.cp'],'wt'); fprintf(fid,'%f %f\n',[temp(:,1)'; temp(:,2)']); fclose(fid); datafiles = strrep(datafiles,strtok(datafiles),' '); [a b] = size(temp); if a ~= 3000, error('You do not have 30 sec. worth of data'); end end set(h,'Pointer','arrow');