Unable to open file with Importdata after dir with subfolders?
5 ビュー (過去 30 日間)
古いコメントを表示
I've used this simple code before with all of my files in one folder and it worked fine.
However I've modified it by adding ** because I now want to get all of the files in subfolders.
The first part of the code seems to be working, it creates a structure from dir with all of my files.
The problem is the second part does not seem to be working as it normally does. I am receiving the erorr message
"Error using importdata (line 137)
Unable to open file."
I'm guessing there is a modification I need to make because I am now using dir with subfolders, but I'm lost as to what change needs to be made.
My goal is to identify all of the files with a specific name, and store the data from those files in variables.
Thank you.
Eyefiles = dir('**\*SMI*')
Vivefiles = dir('**\*Euler*')
%%
for k = 1:length(Eyefiles)
eyedata{k} = importdata((Eyefiles(k).name))
end
for b = 1:length(Vivefiles)
vivedata{b} = importdata((Vivefiles(b).name))
end
0 件のコメント
採用された回答
Walter Roberson
2019 年 2 月 4 日
fullfile(Eyefiles(i).folder, Eyefiles(i).name)
to construct the file name
3 件のコメント
Walter Roberson
2019 年 2 月 4 日
I am not sure off-hand, but I would suggest experimenting with readtable()
Would your files happen to be .xls or .xlsx ? If so I wonder if some of them have multiple sheets?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!