Can't get Simulink model to recognize a Level-2 S-Function using c file

1 view (last 30 days)
Brian Tremaine
Brian Tremaine on 20 Oct 2021
Commented: Brian Tremaine on 20 Oct 2021
I am using Matlab R2021a. I have a simple model in which I am using a Level-2 S-function and providing the name of a compiled C file. The C file name is phase_det.c and the name I put in the C file is #define S_FUNCTION_NAME phase_det
In the Simulink model (test.slx), I use a Level-2 S-Function I entered the name phase_det
This is similar to the Matlab example dsfunc.c. Which I have been successfully able to compile using mex dsfunc, then runnning okay.
Similarly, I was able to compile using mex phase_det.c.
When I run the Simulink model test.slx I get the error " Level-2 MATLAB S-function 'phase_det' does not exist"
I'v been working on this for hours and know it must be something really silly that I missed. Its almost like the phase_det.mexw64 file is not in my running directory, but it is.
I included the zipped files.
Thank-you very much for helping,
  1 Comment
Brian Tremaine
Brian Tremaine on 20 Oct 2021
I am answering my own question. I think the S-Function block I was using was not a CMEX S-Function. I copied a C-code S-Function block from another woring program and edited the block to name it 'phase_det'. Doing this it did work.
The block I orignally used was labeled a 'Level 2 S-Function'. In the Simulink model once the block label is changed, such as calling it 'My Block' instead of 'Level 2 S-Function', it seems that there is now way to no what kind of block it is.
Am I missing something here?

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!