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.

cd('c:\work')

Create a prototype file using the loadlibrary function.

hfile = fullfile(matlabroot,'extern','include','matrix.h');
loadlibrary('libmx',hfile,'mfilename','mxproto')

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.

fcns.alias{fcnNum}='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:

fcns.name{fcnNum}='mxGetNumberOfDimensions'; 
fcns.calltype{fcnNum}='cdecl';
fcns.LHS{fcnNum}='int32'; 
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);
calllib('libmx','mxGetDims',y)
ans =
     3
Was this topic helpful?