We are currently aware of three possible causes for this error message:
1) The error may be due to an invalid character somewhere in a filename or its directory path. Please double-check all paths for any invalid characters that may exist by inspecting the output given by MATLAB when executing:
in the current directory where your project files are located and from where you are building the S-Function.
2) In R2018a and prior, spaces in the temporary directory path have caused this issue, for example:
You can work around this by changing the temporary directory to a folder without spaces at the beginning of your MATLAB session, using the SETENV command. For example:
This cause has been fixed in R2018b.
3) The localization settings on your computer might not be set properly and cause "fopen" to therefore see some irregular characters. For reference, please refer to the following link about the required locale settings:
Please ensure that the user locale and system locale are the same value. If they are different, this might be the reason for the S-Function builder error you are seeing. You might need to restart your computer after making any changes to locales.
You may also check your locale settings by entering the following commands into MATLAB Command Window and see if they match:
>> get(0, 'Language')
>> locale = java.util.Locale.getDefault()
>> language = locale.getLanguage()