Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 7/Programming Assignment - 6/ex6/readFile.m
863 views
1
function file_contents = readFile(filename)
2
%READFILE reads a file and returns its entire contents
3
% file_contents = READFILE(filename) reads a file and returns its entire
4
% contents in file_contents
5
%
6
7
% Load File
8
fid = fopen(filename);
9
if fid
10
file_contents = fscanf(fid, '%c', inf);
11
fclose(fid);
12
else
13
file_contents = '';
14
fprintf('Unable to open %s\n', filename);
15
end
16
17
end
18
19
20