slbuild Simulink model subsystem failure

조회 수: 17 (최근 30일)
Vico Wu
Vico Wu 2023년 1월 18일
댓글: Phab 2025년 6월 4일
I have a simulink model, there is subsystem inside the model, and I want to generate C code from the subsystem in the model using the slbuild function. However, it prompts that only models or model handles can be generated.The help documentation describes the code generation that can be used for subsystem. How can I generate it? I'm using a script generation.
SubSysName = [strSubSysName '/' strBlkName];
slbuild(SubSysName);
Warning: rtwbuild failed to generate code for LmpCtrl,First argument to 'slbuild' must be a model name or a handle to a model.

답변 (1개)

Ganapathi Subramanian
Ganapathi Subramanian 2023년 3월 3일
It is my understanding that you are working on a Simulink model and has an uncertainty in generating C code for a subsystem.
To generate C code for a subsystem, 'slbuild' function is used. The syntax for slbuild function for a subsystem is ‘slbuild(SubSysName)’. Here the ‘SubSysName’ corresponds to the full block path of the subsystem.
SubSysName=[strModelName '/' strSubSysName];
%strModelName is the name of the model which has the subsytem
slbuild(SubSysName);
  댓글 수: 1
Phab
Phab 2025년 6월 4일
Is there a way to build a subsystem without opening the model?
Let's say I want to build the 'myModel/mySubsystem':
open('myModel');
slbuild('myModel/mySubsystem');
works, but without opening the model first the process fails:
% open('myModel');
slbuild('myModel/mySubsystem');
Or is there anyother way to not open the model first?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by