A series of MATLAB functions will follow. Some of these “.m” files call each other, so ensure you have all of them before you start.
The purpose of this file is to load in all the .x00 files in a directory of Omega-Omega-2-Theta slices for reciprocal space mapping of a sample. “OmegAxis” determines the scale for the Omega axis (y) for reciprocal space mapping. [again, this is not yet in Q-space, that will come at a later date]
The first function loads data into your workspace for a directory of .x00 files that have a common base filename. The user needs to supply the first index number and last index number for loading the files. The program then attempts to load “filenameIndex.x00″ in a linear fashion for all .x00 files of that filename indexed in the cd’d directory. [Change directory to the working directory needed before starting this function.]
You can download this file as a text file here: OmegAxis.m, revision 8
function [Omeg, OmegaStep] = OmegAxis(filename,startnum,stopnum) % Program will read representative files in a directory of scans to determine % the appropriate vector for the Omega axis % Let's read the first file's Omega [FirstOmega] fid = fopen(sprintf('%s%i.x00',filename,startnum),'r'); for i = 1:40 C = textscan(fid,'%s',1,'delimiter',','); if strcmp(C{1}, 'Omega') testme = 0; break end end C = textscan(fid,'%f',1,'delimiter',','); FirstOmega = C{1}; fclose(fid); % Let's read the second file's Omega to get the stepsize [SecondOmega] fid = fopen(sprintf('%s%i.x00',filename,(startnum+1)),'r'); for i = 1:40 C = textscan(fid,'%s',1,'delimiter',','); if strcmp(C{1}, 'Omega') testme = 0; break end end C = textscan(fid,'%f',1,'delimiter',','); SecondOmega = C{1}; fclose(fid); % So the stepsize will be [OmegaStep] OmegaStep = SecondOmega - FirstOmega; % Finally, let's read the last file and determine the breadth of the scan [LastOmega] fid = fopen(sprintf('%s%i.x00',filename,stopnum),'r'); for i = 1:40 C = textscan(fid,'%s',1,'delimiter',','); if strcmp(C{1}, 'Omega') testme = 0; break end end C = textscan(fid,'%f',1,'delimiter',','); LastOmega = C{1}; fclose(fid); % record the vector to send back Omeg = [FirstOmega;LastOmega]; return