Documentation Center

  • Trial Software
  • Product Updates

Create Alias Function Name Using Prototype File

This example shows how to create and modify a prototype file, mxproto, to create an alias for the function, mxGetNumberOfDimensions.

Use a folder for which you have write-access.


Create a prototype file using the loadlibrary function.

hfile = fullfile(matlabroot,'extern','include','matrix.h');

MATLAB® creates the prototype file, mxproto.m, in the current folder.

Open the file in MATLAB Editor.

edit mxproto.m

Search for the function mxGetNumberOfDimensions.

The following command assigns the alias mxGetDims.


Add the command to the line before the command to increment fcnNum. The new function prototype, with the new command shown in bold, looks like this:{fcnNum}='mxGetNumberOfDimensions'; 
fcns.RHS{fcnNum}={'MATLAB array'};
fcns.alias{fcnNum}='mxGetDims'; % Alias defined
fcnNum=fcnNum+1; % Increment fcnNum

Reload libmx using the prototype file.

unloadlibrary libmx
loadlibrary('libmx', @mxproto)

Call the function.

y = rand(4,7,2);
ans =
Was this topic helpful?