Why do I receive the error "There is no block named..." when adding a MATLAB file (level-2) S-Function to a SIMULINK model using the function ADD_BLOCK?

35 views (last 30 days)
I receive the following error when adding a MATLAB file (level-2) S-Function to a SIMULINK model using the function ADD_BLOCK:
ERROR: ??? Error using ==> add_block
There is no block named 'simulink/User-Defined Functions/MATLAB file (level-2) S-Function'.
To reproduce this error, you can use the following code:
new_system('mySystem')
open_system('mySystem')
add_block('simulink/User-Defined Functions/MATLAB file (level-2) S-Function', 'mySystem/mySFunction')

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Oct 2022
Edited: MathWorks Support Team on 14 Oct 2022
To work around this issue, add the block as shown below:
add_block('built-in/M-S-Function', 'mySystem/test')
The following URL links to a description of how to add blocks to a model using the add_block function with the block's 'Blocktype' property.

More Answers (0)

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!