s-function in simulink MATLAB

10,741

Solution 1

You need to compile the s function using mex.

Then the mex32 output file needs to be on the matlab path.

Solution 2

It is possible that your version of Matlab is newer
than the version of Matlab used to produce the S-function.

If this is the case, I believe that the S-function
must be recreated in a newer version of Matlab
in order to interface with newer versions of Matlab.

Solution 3

For an S-Function, you need to make sure your C, Matlab, or Fortran Code is where Simulink expects it to be. My guess is your code exists, but isn't in the directory simulink expects.

Right click on the S-Function Block in your Simulink Project -> Choose S-Function Parameters.

Click on the Edit button next to the S-function name.

It will probably tell you the S-Function source cannot be found. It will then prompt you to either browse for the code or open an editor.

If you can't figure out where this file is located and you have the code your best bet is to open the Editor from this dialog box.

From there just paste the code and save it as 'chiu_sfcn'. You don't need to put a file extension, or browse to a different folder. It should automatically save it in the right folder for you.

Share:
10,741
rina
Author by

rina

Updated on June 04, 2022

Comments

  • rina
    rina almost 2 years

    I'm getting message

    Error in S-function 'project1_simu/S-Function': S-Function 'chiu_sfcn' does not exist

    whenever i run my simulink file which contains s-function block diagram. Any tips to resolving this problem?