function r = readLine(path)
arguments
path {mustBeFile}end
fid = fopen(path);
r = fgetl(fid);
fclose(fid)
end
将此文件夹路径传递给 readLine 函数会导致错误。
r = readLine("C:\Users\Public")
Error using readLine (line 3)
r = readLine("C:\Users\Public")
^^^^^^^^^^^^^^^^^
Invalid argument at position 1. These files do not exist: 'C:\Users\Public'.