필터 지우기
필터 지우기

How to import multiple txt files in different folders into workspace at one time?

조회 수: 2 (최근 30일)
Hi, I have multiple txt files stored in several folders and the groups of txt files in the same folder has a similar pattern of file names. All the txt files need to be read starting from the 3rd row. How can I import all the txt files from the different folders at one time into MATLAB workspace and then assign them with different names in the workspace?
Many thanks,
a sincerely user

채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 9월 18일
have you tried "textread" command? It has a headerline parameter that tells how many line to ignore. You need to call that function for each file though.
  댓글 수: 2
anone
anone 2014년 9월 18일
Thanks, that is right but my main issue to import multiple txt files from different folders into workspace at one time, any suggestion for this?
Also, once they are imported into workspace, how can I assign them with different names in a quick way, the original file names are the ideal names.
Thanks.
Mohammad Abouali
Mohammad Abouali 2014년 9월 19일
I wouldn't name them differently. but you can use cell arrays something like this:
for i=1:nFiles
[A,B,C,...]=textread(....);
myData.A{i}=A;
myData.B{i}=B;
myData.C{i}=C;
end
Then you can access the values from different file easily or later you can combine them together.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by