%% Read Entire File of uint8 Data
% Write a nine-element vector to a sample file, nine.bin.

fileID = fopen('nine.bin','w');
fwrite(fileID,[1:9]);
fclose(fileID);

%
% Read all the data in the file into a vector of class double. By default, fread reads a file 1 byte at a time, interprets each byte as an 8-bit unsigned integer (uint8), and returns a double array.

fileID = fopen('nine.bin');
A = fread(fileID)

% fread returns a column vector, with one element for each byte in the file.
%
% View information about A.

whos A

%
% Close the file.

fclose(fileID);

% Copyright 2015 The MathWorks, Inc.