How to get missing files programmatically similar to GUI Dependency Analysis?

9 views (last 30 days)
In Analyze Project Dependencies - MATLAB & Simulink - MathWorks Nordic we read it is possible to do an dependency analysis to find cases where a file cannot be found. Find model file dependencies - MATLAB dependencies.fileDependencyAnalysis - MathWorks Nordic suggests this can be done programmatically for a Simulink model.
For Matlab projects the suggested feature to use is Get files required by specified project files - MATLAB listRequiredFiles - MathWorks Nordic, but this cannot produce a list of missing files same as the others. Clicking in the GUI for Dependency Analysis on the project produces such lists just fine, suggesting something manages to pull it off. Exacyl how eludes me.
Is there a way to get a missing files list programmatically for files in a Matlab Project?

Answers (1)

Poorna
Poorna on 4 Apr 2024
Hi Andreas,
I see that you would like to get the missing files in a MATLAB project programmatically like "dependencies.fileDependencyAnalysis" for simulink models.
Although I am not sure of any readymade function to get all the missing files but I do have a workaround. Starting from MATLAB R2024a, the "findFiles" function is available. You can use this function to list all the files of the project. When you specify the "OutputFormat" as "ProjectFile" the output of the "findFiles" function will now be an array of type "ProjectFile". The "ProjectFile" object has a property called "SourceControlStatus". For all the missing files this property will be set to "Missing".
Therefore, you can filter the project files list based on the "SourceControlStatus" property to get the list of missing files as below:
files = findFiles(proj, "OutputFormat", "ProjectFile");
missingFileIndices = [files.SourceControlStatus] == 'Missing';
missingFiles = files(missingFileIndices);
To know more about the "findFiles" function refer to the following documentation:
Hope this Helps!

Categories

Find more on Dependency Analysis in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!