필터 지우기
필터 지우기

Create folders in matlab and move into files via loop

조회 수: 9 (최근 30일)
Ivan Mich
Ivan Mich 2020년 5월 30일
댓글: Sai Sri Pathuri 2020년 6월 1일
Hello,
I am making via a loop 4 .txt files. I would like to create 4 files and move each one of 4.txt files in these 4 folders (I mean each folder would have one .txt files).
How could I make it?

답변 (1개)

Sai Sri Pathuri
Sai Sri Pathuri 2020년 5월 30일
You may try the following
for i =1:4
currentFolder = sprintf('Folder%d',i);
mkdir(currentFolder)
cd(currentFolder)
fileID = fopen('FileName.txt','w');
% Write to file
cd ..
end
  댓글 수: 6
Ivan Mich
Ivan Mich 2020년 6월 1일
ok, one question. Is there any way to replace dlmwritte with writematrix? I think that the problem is here
Sai Sri Pathuri
Sai Sri Pathuri 2020년 6월 1일
Yes, you may replace dlmwrite with writematrix
writematrix(M,'final.txt','Delimiter','tab')
Refer the below links for replacing dlmwrite and dlmread with writematrix and readmatrix respectively

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by