| Writing S-Functions | ![]() |
Libraries Pane
The Libraries pane allows you to specify the location of external code files referenced by custom code that you enter in other panes of the S-Function Builder dialog box.
The Libraries pane includes the following fields.
Library/Object/Source files
External library, object code, and source files referenced by custom code that you enter elsewhere on the S-Function Builder dialog box. List each file on a separate line. If the file resides in the current directory, you need specify only the file's name. If the file resides in another directory, you must specify the full path of the file.
You can also use this field to specify search paths for libraries, object files, header files and source files. To do this, enter the tag LIB_PATH, INC_PATH, or SRC_PATH, respectively, followed by a comma- or semicolon-separated list of paths. You can make as many entries of this kind as you need but each must reside on a separate line.
For example, consider an S-Function Builder project that resides at d:\matlab6p5\work and needs to link against the following files:
c:\customfolder\customfunctions.lib
d:\matlab7\customobjs\userfunctions.obj
d:\externalsource\freesource.c
The following entries enable the S-Function Builder to find these files:
Customfunctions.lib Userfunctions.obj LIB_PATH c:\customfolder\customfunctions.lib LIB_PATH $MATLABROOT\customobjs Freesource.c SRC_PATH d:\externalsource
As this example illustrates, you can use LIB_PATH to specify both object and library file paths and the tag $MATLABROOT to indicate paths relative to the MATLAB installation. You can also include multiple LIB_PATH entries on separate lines. The paths are searched in the order specified.
You can also enter preprocessor (-D) directives in this field, e.g.,
Each directive must reside on a separate line.
Includes
Header files containing declarations of functions, variables, and macros referenced by custom code that you enter elsewhere on the S-Function Builder dialog box. Specify each file on a separate line as #include statements. Use brackets to enclose the names of standard C header files (e.g., #include <math.h>). Use quotation marks to enclose names of custom header files (e.g., #include "myutils.h"). If your S-function uses custom include files that do not reside in the current directory, you must set the S-Function Builder's include path to the directories containing the include files (see Setting the Include Path).
External function declarations
Declarations of external functions not declared in the header files listed in the Includes field. Put each declaration on a separate line. The S-Function Builder includes the specified declarations in the S-function source file that it generates. This allows S-function code that computes the S-function's states or output to invoke the external functions.
| Data Type Attributes Pane | Outputs Pane | ![]() |
© 1994-2005 The MathWorks, Inc.