Generate Simulink model from script

Is there a way to generate an SLX model from a Matlab script? I have a custom Simulink library and the models I want to automatically generate vary in their design and I'm trying to figure out the easiest way to script their generation. I already have a script that generates text code for an MDL format model and it works fairly well but now I'm looking to update to the SLX format and have an easier codebase for users to both develop and understand. My text generation is rather difficult because it pieces text together and is hardcoded for a specific Simulink release format. Thanks!

답변 (2개)

tran
tran 2018년 1월 31일
편집: tran 2018년 1월 31일

1 개 추천

Yes, there is.
You can generate a model with matlab code (both function and script) follow links:
[1]. https://blogs.mathworks.com/simulink/2010/01/21/building-models-with-matlab-code/
[2]. https://www.mathworks.com/help/simulink/ug/approach-modeling-programmatically.html
You can use the body instead. The result will be a simulink model. That just my idea and I never try before.

댓글 수: 1

Thomas Marullo
Thomas Marullo 2018년 2월 12일
Thank you. This is helpful however I was curious because it is 8 years old if there are newer techniques that are used with SLX models since these generate the older MDL file types.

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

Marco Gavelli
Marco Gavelli 2018년 8월 13일
편집: Marco Gavelli 2018년 8월 13일

1 개 추천

You could also give the Matsim library a try (disclaimer: I'm the developer). Matsim is a wrapper around the standard Simulink API to add:
  • Automatic layout (no need to specify block positions!)
  • Intuitive interface (you can "add", "subtract", "multiply", ... simulink blocks)
  • Compatible with any release from R2011b onwards
  • No problem saving the model to MDL or SLX
Quick sample:

댓글 수: 4

Mohamed
Mohamed 2023년 3월 14일
Hi sir, I have just seen your library, I am working on a tool that seems to your work on my end of studies project and i need your help if it is possible, Thank you in advance.
Man the Matsim API is awesome, I don't know how it is not more known.
I'm currently using it in a project I'm making
Thomas Marullo
Thomas Marullo 2023년 8월 14일
This looks like a great solution. Does it support the current version?
hi. i have problem tu install the Matsim. it is not running properly. it there any new version of matsim?because i cant find it. thanks

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

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

질문:

2018년 1월 25일

댓글:

2024년 6월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by