function norbload() fid=fopen('smallnorb-5x46789x9x18x6x2x96x96-training-dat.mat','r'); fread(fid,4,'uchar'); % result = [85 76 61 30], byte matrix(in base 16: [55 4C 3D 1E]) fread(fid,4,'uchar'); % result = [4 0 0 0], ndim = 4 numImages = fread(fid,4,'uchar'); % result = [236 94 0 0], dim0 = 24300 (=94*256+236) fread(fid,4,'uchar'); % result = [2 0 0 0], dim1 = 2 fread(fid,4,'uchar'); % result = [96 0 0 0], dim2 = 96 fread(fid,4,'uchar'); % result = [96 0 0 0], dim3 = 96 s = ['norb.trainingStates.dat'] fid2 = fopen(s, 'w'); fprintf(fid2, '%d\n', 100); for n=1:200, im = reshape(fread(fid,96*96),96,96)/256; if (mod(n, 2) == 0) data = im(:); jwrite(fid2, data); end end; fclose (fid); fclose (fid2);