Borrar filtros
Borrar filtros

Hi i'm new to Matlab. i have directory : C:\D\Test and inside the ''Test'' i got sub folders A,B,C,D and E. i have a m.file called ''test.m'' in each sub folder. i wanna automate the run each test.m starting from A and then until E .

1 visualización (últimos 30 días)
here is the code I tried before, however it does not work.
dirinfo = dir('C:\D\Test');
dirinfo(~[dirinfo.isdir]) = [];%remove non-directories
subdirinfo = cell(length(dirinfo));
for i = 1 : length(dirinfo)
thisdir = dirinfo(i).name;
subdirinfo{i} = dir(fullfile(thisdir,'test.m'));
run(fullfile(thisdir,'test.m'));
end
here is the error message I get:
Error using run (line 73)
.\test.m not found.
Error in fish (line 7)
run(fullfile(thisdir,'test.m'));

Respuesta aceptada

OCDER
OCDER el 28 de Sept. de 2017
You also have to remove the '.' and the '..' directories that are returned by dir
dirinfo = dir('C:\D\Test');
dirinfo(~[dirinfo.isdir]) = []; %remove non-directories
dirinfo(endsWith({dirinfo.name}, '.')) = []; %removes the '.' and '..' directories

Más respuestas (0)

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by