Main Content

MATLAB Prototype Files

When to Use Prototype Files

MATLAB® provides a way to modify header file information by creating a prototype file, a file of MATLAB commands.

Like a header file, the prototype file contains the function signatures for the library. Here are some reasons for using a prototype file.

  • To deploy applications that use loadlibrary (using MATLAB Compiler™).

  • To use loadlibrary in a parallel computing environment (using Parallel Computing Toolbox™).

  • To change signatures of the library functions.

  • To rename some of the library functions.

  • To use only a small percentage of the functions in the library you are loading.

  • To use functions with a variable number of arguments.

You can change the prototypes by editing the prototype file and reloading the library.

How to Create Prototype Files

To create a prototype file, use the mfilename option of the loadlibrary function.

How to Specify Thunk Files

For information about default thunk file names, see loadlibrary. To change the name, use the thunkfilename option.

Deploy Applications That Use loadlibrary

To deploy a MATLAB application that uses loadlibrary, using MATLAB Compiler:

  • Create a prototype file.

  • For 64-bit applications, specify a thunk file.

  • Include all the relevant files when creating the project with mcc.

loadlibrary in Parallel Computing Environment

To use loadlibrary in a parallel computing environment (using Parallel Computing Toolbox):

  • Create a prototype file.

  • For 64-bit applications, specify a thunk file.

  • Make sure that all relevant files are accessible to all workers.

Change Function Signature

Edit the prototype file, changing the fcns.LHS or fcns.RHS field for that function. This edit changes the types of arguments on the left-hand side or right-hand side, respectively.

Rename Library Function

Edit the prototype file, defining the fcns.alias field for that function.

Load Subset of Functions in Library

Edit the prototype file, commenting out the unused functions. This edit reduces the amount of memory required for the library.

Call Function with Variable Number of Arguments

Create an alias function in a prototype file for each set of arguments you use to call the function.