time | Calls | line |
|---|
| | 1 | function out=fileread(filename)
|
| | 2 | %FILEREAD Return contents of file as a character vector.
|
| | 3 | % TEXT = FILEREAD(FILENAME) returns the contents of the file FILENAME.
|
| | 4 | %
|
| | 5 | % See also FREAD, TEXTSCAN, LOAD, READTABLE, UIIMPORT, IMPORTDATA
|
| | 6 |
|
| | 7 | % Copyright 1984-2018 The MathWorks, Inc.
|
| | 8 |
|
| 1 | 9 | narginchk(1, 1);
|
| | 10 |
|
< 0.001 | 1 | 11 | filename = convertStringsToChars(filename);
|
| | 12 |
|
| 1 | 13 | if ~ischar(filename)
|
| | 14 | error(message('MATLAB:fileread:filenameNotString'));
|
| 1 | 15 | end
|
| | 16 |
|
| 1 | 17 | if isempty(filename)
|
| | 18 | error(message('MATLAB:fileread:emptyFilename'));
|
| 1 | 19 | end
|
| | 20 |
|
< 0.001 | 1 | 21 | [fid, msg] = fopen(filename);
|
| 1 | 22 | if fid == -1
|
| | 23 | error(message('MATLAB:fileread:cannotOpenFile', filename, msg));
|
| 1 | 24 | end
|
| | 25 |
|
< 0.001 | 1 | 26 | try
|
0.006 | 1 | 27 | out = fread(fid,'*char')';
|
| | 28 | catch exception
|
| | 29 | fclose(fid);
|
| | 30 | throw(exception);
|
< 0.001 | 1 | 31 | end
|
| | 32 |
|
< 0.001 | 1 | 33 | fclose(fid);
|
Other subfunctions in this file are not included in this listing.