Model Compilation Through M-Script

My question is I got 36 models(all in slx format) present in structure array under the field 'name'.My Objective is to compile each model one after another through M-script
The script I written is as below
sort_slx_files = dir('*.slx'); The models are present in the directory
for i = 1:length(sort_slx_files)
load_system(sort_slx_files(i).name)
(sort_slx_files(i).name([],[],[],'compile'));
end
But I get the error 'Index exceeds matrix dimension'
How to resolve this error and get the objective of compiling the models one after another

 採用された回答

Fangjun Jiang
Fangjun Jiang 2019 年 10 月 4 日
編集済み: Fangjun Jiang 2019 年 10 月 4 日

0 投票

sort_slx_files(i).name is a string, that is the cause of the error.
use eval([sort_slx_files(i).name,'([],[],[],''compile'');']);

3 件のコメント

Rahul
Rahul 2019 年 10 月 4 日
Hi, I will try this on Wednesday and let you know if it has worked .Thank you very much for the answer
Fangjun Jiang
Fangjun Jiang 2019 年 10 月 4 日
編集済み: Fangjun Jiang 2019 年 10 月 4 日
also, don't forget to run eval([sort_slx_files(i).name,'([],[],[],''term'');']); and close_system().
Rahul
Rahul 2019 年 10 月 9 日
Thank you very much I am able to compile the models by inserting this piece of code too
sort_slx_files(i).name = strrep(sort_slx_files(i).name,'.slx','')
Then I applied your piece of code
eval([(sort_slx_files(i).name),'([],[],[],''compile'');']);
Thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgrammatic Model Editing についてさらに検索

製品

リリース

R2016b

タグ

質問済み:

2019 年 10 月 4 日

コメント済み:

2019 年 10 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by