MATLAB: 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

foundlevel-2level2m-fileMATLABmisspellmisspellednamenotr14s-functionsp1spacesspell

I receive the following error when adding a MATLAB file (level-2) S-Function to a SIMULINK model using the function ADD_BLOCK:
??? 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')

Best Answer

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.