function S = loadAgilent(filename) fid = fopen(filename); %open the file for reading fseek(fid, 9, 'bof'); %skip past the first 9 bytes of the header bands = fread(fid, 1, 'int16'); %read the number of bands in the file fseek(fid, 13, 'cof'); %skip the next 13 bytes in the header samples = fread(fid, 1, 'int16'); %read the number of samples (X) lines = fread(fid, 1, 'int16'); %read the number of lines (Y) fseek(fid, 1020, 'bof'); %skip past the entire header S = fread(fid, [samples lines*bands], 'float32'); %read all the data S = reshape(S, [samples, lines, bands]); fclose(fid); %close the file