MATLAB修改某一行txt的内容

for j=1:200
    cd(['CASE_',num2str(j)];
    fileID = fopen('mdm_reg.txt','r+');
    i=0;
    while ~feof(fileID)
        tline=fgetl(fileID);
        i=i+1;
        newline{i} = tline;
        if i==20
            newline{i} = strrep(tline,'1719d7b6',accesscode(j,:));
        end
    end
    fclose(fileID);
    fileID = fopen('mdm_reg.txt','w+');
    for k=1:i
        fprintf(fileID,'%s\t\n',newline{k});
    end
    fclose(fileID);
    cd('..');
end

 

你可能感兴趣的:(软件相关)