We'll develop the simplest possible S-functions to enable our models to communicate with the application we described earlier: a file-source block and a file-sink block.
These S-functions will have only one port and be able to read/write a scalar real signal from/to a file. The file path will be passed as a parameter; and the files will have only one line containing the new signal value.
The sink block, called
filesink_msfun, will receive the input and convert it to a string that will be written to the file. The file path is passed as parameter, no
DWork vector is needed because we don't have to output a default value.
The source block, called
filesource_msfun, will read one line from the file, attempt ...