Compile Parametrized Simulink model name

조회 수: 7 (최근 30일)
Steve Oswald
Steve Oswald 2021년 11월 4일
답변: Fangjun Jiang 2021년 11월 9일
Hello,
I'd like to compile a parametrized model name by variable. e.g.:
modelname = get_param(bdroot, 'Name');
modelname([],[],[],'compile');
When I execute the code, I get:
>Index in position 4 exceeds array bounds (must not exceed 1).
I expected it to compile the model. Since modename = "TheModel", when I execute the following code:
TheModel([],[],[],'compile')
The model compiles successfully, however, I cannot parametrize the name of the model. I want to clarify:
I need to compile a model, which's name I have only stored in a variable.
Thank you in advance!
Kind regards,
Steve

채택된 답변

Fangjun Jiang
Fangjun Jiang 2021년 11월 9일
In this case, you might have to use eval()
MyCommand=[modelname,'([],[],[],''compile'')'];
eval(MyCommand);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by