O'Reilly logo

Getting Started with Simulink by Luca Zamboni

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MATLAB S-functions – file source and sink blocks

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required