필터 지우기
필터 지우기

How do I create a S-Function with generated Code (Simulink Coder)?

조회 수: 3 (최근 30일)
Ps222015
Ps222015 2015년 11월 17일
댓글: Bharat 2020년 9월 30일
I want to generate Code from a Model (e.g. a Subsystem), modify the Code, and create a S-Function with the modified Code. The Code-generation isn't the Problem - i think - I'm just using Simulink Coder to generate the Code. The Problem is to create a S-Function with the generated Code. It doesnt work, even if I dont modify the Code.
What I've tried:
  • Creating a .mexw64 file by using "mex" in the Console - that worked so far, but I couldnt connect the mex file with a S-Function.
  • Using legacy code Tool - the S-Function I generated with legacy_code doesnt have In/Output ports. The OutputFcnSpec of legacy code would be very much effort to write, if its a complex model.
Is there an easy way to do this?
  댓글 수: 1
xida zhou
xida zhou 2019년 5월 8일
What I know is that you cann't create a S-function by use the code which generated by Simulink coder. If you want to create a S-function in a simple way, you should follow Madhu Govindarajan's answer.

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

답변 (2개)

Madhu Govindarajan
Madhu Govindarajan 2015년 11월 19일
You can create subsystems out of algorithms that are of concern and right click on the subsystem > C/C++ code > generate S-function, this way you can create the S-function directly without having to create the code and modify it. But if that is part of your workflow then I am not sure how to go about this, maybe there is a way to parameterize stuff in S-functions.
  댓글 수: 1
Bharat
Bharat 2020년 9월 30일
Hi Madhu, What you are saying that, if we follow right click on the subsystem > C/C++ code > generate S-function. Which means we don't need to generate code for S-function correct?
Is this apply for Targetlink block in simulink model?

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


Yaswanth Siramdasu
Yaswanth Siramdasu 2018년 9월 27일
Thanks Madhu. Neat and simple it worked perfectly.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by