S-Function 'ExampleFunction' does not exist

7 ビュー (過去 30 日間)
Vincent K
Vincent K 2019 年 4 月 11 日
回答済み: Anay 2025 年 7 月 1 日
Hello,
I am facing an error that completely puzzles me. Let's have the following scenario:
I copy the sfun_counter_cpp.cpp from the Matlab examples folder into another directory. In the same directory I create a Simulink Model with an S-Function calling the cpp file. Everyhing works. Now I do the same as before, but now I rename the file to 'sfun_test_cpp.cpp' and every encounter of the expression 'sfun_counter_cpp' in the file to 'sfun_test_cpp'. I also edit the S-Function accordingly and now... 'sfun_test_cpp' doesn't exist!
I am trying to debug this error for more than 2 hours now. What the heck is wrong here?

回答 (1 件)

Anay
Anay 2025 年 7 月 1 日
Hi Vincent,
In order to use C++ S-functions you must compile them into MEX files. The error “<file name> doesn't exist!” means that the MEX file with the same name is missing, not the CPP file.
You must use the following command to compile your CPP file to MEX file:
mex sfun_test_cpp.cpp
This should solve the error of missing file.
You can consider following below links to learn more about basics of S-functions and MEX files:

カテゴリ

Help Center および File ExchangeBlock and Blockset Authoring についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by