Writing S-Functions    

An Example Involving a Pointer Work Vector

This example opens a file and stores the FILE pointer in the pointer-work vector.

The statement below, included in the mdlInititalizeSizes function, indicates that the pointer-work vector is to contain one element.

The code below uses the pointer-work vector to store a FILE pointer, returned from the standard I/O function, fopen.

This code retrieves the FILE pointer from the pointer-work vector and passes it to fclose to close the file.

The synopsis is

For an example, see matlabroot/simulink/src/sfun_dynsize.c.


 Work Vectors and Zero Crossings Memory Allocation