% the following is a typical first attempt to read the binarytest_uchar % file - it reads the data, but organises it wrongly. Remember that matlab % address matrices column bu column. fd = fopen('binarytest_uchar.bin'); data = fread(fd,'uchar') data = 1 1 2 4 3 9 4 16...etc... % this reads in the data, but since no size is specified for the matrix % 'data', it defaults to a single column. The data was written out from the % array: 1 2 3 4 5 6 7 8 9 10 1 4 9 16 25 36 49 64 81 100 % in column order, ie: 1 1 2 4 3 9 4 16...etc, which is how it is read in % above. To recover the shape of the required matrix we need to specify the % size/shape of the desired output matrix: data = fread(fd,[2 inf],'uchar') % The 'count' variable [2 inf] instructs the fread function to put the data % into a matrix that has 2 rows, and as many columns as required to hold % all the data. We would now get data = 1 2 3 4 5 6 7 8 9 10 1 4 9 16 25 36 49 64 81 100