How can I automatically find the input files a function or script uses?

The "matlab.codetools.requiredFilesAndProducts" function will return a list of program files needed for a program, but it will not include input files that the program loads, such as .mat files, a read of a spreadsheet or text file, etc. How can I automatically find all dependencies for a program that includes all input files needed?

 Respuesta aceptada

dpb
dpb el 30 de Abr. de 2026 a las 14:07
Movida: Matt J hace alrededor de 7 horas
Static analysis can't unless everything is hardcoded...and then would have to parse the code to find the pieces-parts making up the filenames.
function res=myfunc(fn)
data=readmatrix(fn);
...
res=...;
end
What is the above supposed to return for the most simple of issues...
Or, another very common coding paradigm...
d=dir('*.xlsx');
for i=1:numel(d)
tData=readtable(fullfile(d(i).folder,d(i).name));
...
end
Here one could in theory go do the dir() listing but the results can be changed at any time.

1 comentario

+1 Two identical copies of the same function Mfile saved in two different directories could access very different data files and call completely different functions (of the same name), even if everything is "hardcoded". Static analysis is certainly no substitute for runtime!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 30 de Abr. de 2026 a las 12:47

Comentada:

hace alrededor de 23 horas

Community Treasure Hunt

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

Start Hunting!

Translated by