What's the best approach for learning S-Function development

3 views (last 30 days)
I'm coming to Simulink from an MSC simulation platform and it has become immediately obvious to me that I am going to have to develop some of my own custom S-Functions.
I have several questions that I'm hoping to get answered up front so I can hopefully "do it right the first time".
Most importantantly.... is there any good, up to date, learning materials for S-function development that start from the basics can go to the advanced? Cost of the materials is not an issue as my employer will be paying.
From my reading fo teh Matlab Help documentation it appears that C-file S-functions are the best supported. Is that an accurate assessment? Should one be learning C-file right from the beginning? Is there any benefit of one type of S-function over the other?
Any help pointing the right direction is greatly appreciated.

Answers (2)

Kaustubha Govind
Kaustubha Govind on 27 Sep 2011
See Comparison of Custom Block Functionality for an extensive comparison of the capabilities of each type of S-function.
For learning, as Fangjun suggested, I've found the S-function documentation useful. The best way is to practice writing S-functions for simple examples. Type "sfundemos" at the MATLAB prompt to see some examples - you could try recreating some of the examples by yourself and then compare to the actual solution.

Fangjun Jiang
Fangjun Jiang on 27 Sep 2011
The S-function section of the Simulink document is sufficient for you to start writing S-function.
I prefer S-function using MATLAB .m file because it's easy to debug in MATLAB environment. But if you have to use some existing functions in C or other language, then you probably need to use that language.
And if you need to generate C code from your Simulink model later on, then it's probably better to use C for S-function.

Products

Community Treasure Hunt

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

Start Hunting!