addpw.m
来自「matlab book matlab book2」· M 代码 · 共 34 行
M
34 行
function success = addpw(NAME,pwtoadd)
% takes username and password, adds username to list and creates file with
% password signal data
%
% append username to list, with one username per list
ulist = fopen('userlist.txt','a');
if (ulist < 0)
error('could not open file');
success = 0; return;
end;
fprintf(ulist,'%s\n',NAME);
fclose(ulist);
% create file of signal data
pfilename = [NAME '.txt'];
pfile = fopen(pfilename,'w');
if (pfile < 0)
error('could not open file');
success = 0; return;
end;
% write data to file
[pwrows,pwcols] = size(pwtoadd);
for rcount = 1:pwrows
for ccount = 1:pwcols % should be 12 (number of co-efficients)
fprintf(pfile,'%f\n',pwtoadd(rcount,pwcols));
end;
end;
fclose(pfile);
success = 1; % output that files changed/added successfully
% otherwise zero
return;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?