retrievepw.m

来自「matlab book matlab book2」· M 代码 · 共 26 行

M
26
字号
function savedpw = retrievepw(NAME)
%
colcount = 12; % number of coefficients
pfilename = [NAME '.txt']; % create filename using username 
pfile = fopen(pfilename,'r');
if (pfile < 0)
   error('could not open file');
end;

% count number of rows
rowcount = 1;
row = fgetl(pfile);
while (ischar(row))
    rowcount = rowcount + 1;
    row = fgetl(pfile);
end;

frewind(pfile);

% convert file data to matrix of rowcount-by-12 
rowcount = (rowcount-1)/12;
savedpw = char(zeros(rowcount,colcount));
savedpw = fscanf(pfile,'%f',[rowcount colcount]);

fclose(pfile);
return;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?