MATLAB: Script will not run on windows 2016ML, but does on mac 2017ML

load

cd = 'D:\Batch_load'
%%load all data files
files= dir ('*.txt');
for i=1:length(files)
eval(['load ' files(i).name ' -ascii']);
end
Error using load
Unknown text on line number 1 of ASCII file ._WG_10_clean.txt
"".
Error in batch_load (line 9)
eval(['load ' files(i).name ' -ascii']);
There are 54 text files that all have identical formats. File 10 is no different.

Best Answer

Check for UTF-8 or UTF-16 encoding in the file when the successful ones do not have it.
... and don't use eval()
data{i} = load( files(i).name, '-ascii' );
Related Question