%% Get Most Recent Error Message
% Return the details for the most recent file I/O error on a file that you specify.
%
% Open the file to read.

fid = fopen('outages.csv','r');

%
% Set the read position to -5 bytes from the beginning of the file. Since no data exists before the beginning of the file, fseek returns -1 indicating that the operation was unsuccessful.

status = fseek(fid,-5,'bof')

%
% Get the details on the most recent error message on the file using its file identifier fid.

error = ferror(fid) 

%
% Close the file.

fclose(fid);

% Copyright 2012 The MathWorks, Inc.