Recursive directory search for all models

7 次查看(过去 30 天)
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????

回答(1 个)

Abhas
Abhas 2023-7-5
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!

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by