📄 wstextread.m
字号:
function cas = wstextread(sFileName, cDlm)
%WSTEXTREAD puts a delimited file in a cell array of strings.
% CAS = WSTEXTREAD(SFILENAME, CDLM) returns the contents of
% file SFILENAME delimited with the delimiter character CDLM
% in CAS, a cell array of strings.
% CAS = WSTEXTREAD(SFILENAME) uses the tab character as the
% default delimiter.
%
% Author(s): M. Greenstein, 05-27-98
% Copyright 1998-2000 The MathWorks, Inc.
% $Revision: 1.5 $ $Date: 2000/05/22 20:40:27 $
% Initializations
cas = {};
cD = char(9);
% Argument checking
if (nargin < 1)
error('Insufficient number of arguments.');
end
if (~ischar(sFileName))
error('The filename argument is not a character array.');
end
if (nargin > 1)
if (~ischar(cDlm))
error('The delimiter argument is not a character.');
end
cD = cDlm(1);
end
% Attempt to open the input file.
fid = fopen(sFileName, 'rt');
if (-1 == fid)
error(['File open failure for: ' sFileName '.']);
end
% Read through the file.
i = 1;
while (i)
line = fgetl(fid);
if (isnumeric(line)), break; end
j = 1;
while (j)
[s, line] = strtok(line, cD);
if (~length(s)), break; end
cas{i, j} = s;
j = j + 1;
end
i = i + 1;
end
fclose(fid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -