Download presentation
1
S-Functions in Simulink
Using Matlab and S-Function Builder
2
S-Functions Stands for “System Functions”
Custom-built Simulink blocks using C, C++, Fortran, or Matlab. Makes use of a special S-function API Involve three main concepts: Inputs, Outputs, and Action
3
Why do we need them? To simplify complex Simulink models
To handle external hardware, programs, or files To cut calculation time Event-specific reactions in code (excluding matlab)
4
Simulink – Gain Block Gain: Take input, multiply by value to produce output.
5
Matlab Example – Gain Block
Replace gain block with custom s-function One input Multiply by 2 One output
6
Matlab Example – Gain Block
Check out the code now: s_doubler.m
7
Function Builder Example – Gain Block
8
Simulink – Product Block
Product: Takes numerous inputs and multiplies them together
9
Matlab Example – Product Block
Simply replace product block with your Matlab S-Function Block 2 Inputs Amount defined by internal code Operates exactly the same
10
Matlab Example – Product Block
Check out the code now: s_multiplier.m
11
Function Builder Example – Product Block
12
Matlab Example – Throttle Limiter
Input: Wave from -100 to 100, with noise Desired output: Scale between -1 and 1, even with noise
13
Matlab Example – Throttle Limiter
14
Simulink Example – Throttle Limiter
Built after Matlab S-Function Works entirely the same
15
Function Builder Example – Throttle Limiter
16
Creating an S-Function - Matlab
Load up the template.m file Let’s walk through the throttle limiter
17
Creating an S-Function – Function Builder
Load up the fb_limiter.mdl Let’s walk through the steps
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.