Recursive directory search for all models
7 views (last 30 days)
Show older comments
My professor and I want to test a system for all the models present in a directory. Instead of passing all the models separately by using varargin, can I somehow generate all the models in a directory as a string,so that I can split it across a .slx and get the models and test my system in one go????
0 Comments
Answers (1)
Abhas
on 5 Jul 2023
Hi Rohit,
Instead of writing a recursive function to get all the models of a directory, you can use a simple regex match. The line of code attached below will return a structure array with many fields, one of which is the name field. You can use the dot operator to access all the names or you can use the struct2cell function which will directly return the whole structure as cell array, which you can filter out to get the .slx models.
models=dir(fullfile(dirPath,'**/*.slx'));
You can refer this link to know more about :- https://www.mathworks.com/help/matlab/ref/regexp.html
Hope this helps!
0 Comments
See Also
Categories
Find more on Search Path in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!