Simulink Custom Library of S-Functions

조회 수: 2 (최근 30일)
SRance
SRance 2020년 9월 30일
댓글: Fangjun Jiang 2020년 10월 16일
Hi all,
I am looking to create a simulink custom library, with s-functions in it, however am a little confused by the process.
I understand normally you may make a library .slx and cut subsystems into it to create your library, then link this to the normal Library Browser to use elsewhere. However with s-functions, as these are support by additional code, I am unclear how this is meant to work without breaking links to supported file(s).
Has anyhow done this before and have a process for linking?
For some context, I am making a library for Arduino hardware with the aim to have a folder structure that has the library at the top level with subfolders containing each block .slx model with supported .c/.cpp/.h and build files to support the s-functions, such as below.
Thanks in advance!

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2020년 9월 30일
Usually, to make a S-function work, you need to compile the source code into a .dll file or .mex file using mex().
So for a customized library with 10 S-Function blocks, I would make it a single .slx file containing the 10 blocks and provide the 10 .dll files. The files can be anywhere as long as they are in the path.
  댓글 수: 2
SRance
SRance 2020년 10월 16일
Would there happen to be a tutorial on that process? I am likely to need to work through it step-by-step.
At the moment I am assuming I build all the S-Functions in the Library so that I have all the .mex files with the library .slx, though recognise I'll end up with a mass of files.
Currently I've just made the Simulink S-Functions through building in Simulink then altering the .c wrapper; extern "C" before all the void functions and changing to .cpp. This has then been compiled onto my Arduino and tested, and am happy with the functionality - obviously now wanting to link those into a library.
Output wise (as in the screenshots below) I can see the .mexw64, though not really sure what to do with it to then build the library.
Fangjun Jiang
Fangjun Jiang 2020년 10월 16일
See S-Function examples. Build one first.
web(fullfile(docroot, 'simulink/sfg/s-function-examples.html'))

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

카테고리

Help CenterFile Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by