Error using importdata in Matlab to import .txt files by reading the filenames from a cell -
here code (simplified):
dir = dir('c:\folder\subfolder_1\subfolder_2'); allfiles = {dir(~[dir.isdir]).name}; = 1:length(allfiles); info = importdata(allfiles{i}); end
the error occurs on line importdata statement:
error using importdata (line 137) unable open file. error in main (line 29) info = importdata(allfiles{i});
edit 1: same directory in in previous case, when do,
allfiles = {('c:\folder\subfolder_1\subfolder_2\file1.txt'),... ('c:\folder\subfolder_1\subfolder_2\file2.txt')}; = 1:length(allfiles); info = importdata(allfiles{i}); end
i don't error , files read in fine.
your syntax okay (atleast works on here).
have checked if pwd (present workingdirectory) c:\folder\subfolder_1\subfolder_2 when run statement?
if not consider concatenating absolute path:
path = 'c:\folder\subfolder_1\subfolder_2\'; dir = dir(path); allfiles = {dir(~[dir.isdir]).name}; = 1:length(allfiles) absolutefilelocation = [path allfiles{i}]; info = importdata(absolutefilelocation); end
matlab file text
No comments:
Post a Comment