Matlab/Simulink S-Function example: Square a number

The following simple S-Function examples squares the real input value and outputs the squared value.

square.cpp

Makefile

Step-by-step guide of how to add the S-function

Example usage:

Simulink Square SFunction

The output here is 64 because 8*8=64.


Check out similar posts by category: Matlab/Simulink