for j = 1:22
fidin = fopen(['C:\Users\Administrator\Desktop\hbq\Test',num2str(j),'.txt']);
fidout = fopen(['C:\Users\Administrator\Desktop\hbq1\Test',num2str(j),'.txt'],'w');
index =0;
while ~feof(fidin) %?????????
tline=fgetl(fidin);
index =index+1
str{index} = tline;
end
rand_index = randperm(index);
for i=1:index
fprintf(fidout, '%s\n',str{rand_index(i)});
i
end
fclose(fidin);
fclose(fidout);
end
matlab 随机打乱txt文件的每行顺序
最新推荐文章于 2022-05-24 09:56:52 发布