0001 function [fid] = open_file_w_byte_order(filename,version_parameter);
0002
0003
0004
0005 fid = fopen(filename,'rb','n');
0006 version = fread(fid,1,'int16');
0007
0008 if version ~= version_parameter
0009 fclose(fid);
0010 fid = fopen(filename,'rb','b');
0011 version = fread(fid,1,'int16');
0012 end;
0013
0014 if version ~= version_parameter
0015 fclose(fid);
0016 fid = fopen(filename,'rb','l');
0017 version = fread(fid,1,'int16');
0018 end;
0019
0020 if version ~= version_parameter
0021 error('tried both byte orders. this is not the right type of file');
0022 end;
0023
0024 frewind(fid);