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
1 件のコメント
Stephen23
2014 年 9 月 19 日
Do not create or use variable names dynamically like this. Use a cell array or structure instead:
採用された回答
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 件のコメント
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 Center および File Exchange で Files and Folders についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!