フィルターのクリア

Recursive directory search for all models

9 ビュー (過去 30 日間)
Rohit
Rohit 2023 年 7 月 5 日
回答済み: Abhas 2023 年 7 月 5 日
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 Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by