Opening multiple files with similar names in MATLAB: importdata cannot open the files given the name by strcat or dir -


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:

  1. the strcat solution 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 modify strcat input string strcat('int_', num2str( k, '%03d' ), '.asc');

  2. you can use strategy similar this one. see update answer got.

  3. the input gave dir function wrong has dir('int_*.asc') , not dir('int_00_*.asc').


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -