mex folder with all elements

조회 수: 4 (최근 30일)
ander
ander 2015년 2월 2일
답변: Jan 2015년 2월 2일
Hi everyone, and sorry for my English. I am trying to mex some files and my problem is that I have different file in diferent folders. I wanto to know if it is possible to say to the mex command where are all the files, but generally. for example I have five different folders which all they are subfolders of other one.
/my documents/home/home.cpp /my documents/job/job.cpp /my documents/garden/garden.cpp
is possible to say that all elements are in /my documents/??? the same question for the includes.
Thanks to all

채택된 답변

Jan
Jan 2015년 2월 2일
There are a lot of submissions for recursive directory searching in the FileExchange. See:

추가 답변 (1개)

Titus Edelhofer
Titus Edelhofer 2015년 2월 2일
Hi,
not really. You can add all files of one folder by
/my documents/*.cpp
but that doesn't include sub folders. You could write a script using "dir" to recursively go into each folder and add all .cpp files, something like (not tested!):
function list = dirForCpp(list, folder)
% add all .cpp from this folder
files = dir(fullfile(folder, '*.cpp'));
for i=1:length(files)
list{end+1} = fullfile(folder, files(i).name);
end
% now add recursively from sub folders
files = dir(folder);
for i=1:length(files)
if files(i).isdir && ~strncmp(files(i).name, '.')
list = dirForCpp(list, fullfile(folder, files(i).name));
end
end
You call this as
list = dirForCpp({}, '/my documents');
Titus

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by