Opening multiple files with similar names in MATLAB: importdata cannot open the files given the name by strcat or dir -
this question has answer here:
as shai , ctzstef suggested, when have open multiple files similar names in matlab, have do
for k=1:size(fls) filename = strcat('int_',num2str(k),'.asc'); a(k) = importdata(filename, ' ', 9); x(k) = a(k).data(:,1); y(k) = a(k).data(:,2); end or also
fls = dir('int_00_*.asc'); fi=1:numel(fls) a(fi) = importdata(fls(fi).name, ' ',9); end well, problem none of them works. should do? problem matlab version?
you need follow answers got more closely:
the
strcatsolution cannot handle 0 padding of file names. you'll ahve manually rename files'int_001.asc''int_1.asc'.
update (due @dedekmraz's comment): you'll need modifystrcatinput stringstrcat('int_', num2str( k, '%03d' ), '.asc');you can use strategy similar this one. see update answer got.
the input gave
dirfunction wrong hasdir('int_*.asc'), notdir('int_00_*.asc').
Comments
Post a Comment