MATLAB 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 make changes to 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 make changes to the prototypes by editing the prototype file and reloading the library.

How to Create a Prototype File

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

How to Specify a Thunk file

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.

Use loadlibrary in a 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 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 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 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.

Was this topic helpful?