MATLAB Compiler | ![]() ![]() |
Compiling MATLAB Provided M-Files Separately
The M-file mrank.m
contains a call to rank
. The MATLAB Compiler translates the call to rank
into a C call to mlfRank
. The mlfRank
routine is part of the MATLAB M-File Math Library. The mlfRank
routine behaves in stand-alone applications exactly as the rank
function behaves in the MATLAB interpreter. However, if this default behavior is not desirable, you can create your own version of rank
or mlfRank
.
One way to create a new version of rank
is to copy MATLAB's own source code for rank
and then to edit this copy. MATLAB implements rank
as the M-file rank.m
rather than as a built-in command. To see MATLAB's code for rank.m
, enter
type rank
Copy this code into a file named rank.m
located in the same directory as mrank.m
and main.m
. Then, modify your version of rank.m
. After completing the modifications, compile rank.m
.
mcc -t rank
Compiling rank.m
generates file rank.c
, which contains a function named mlfRank
. Then, compile the other M-files composing the stand-alone application.
mcc -t main.m (producesmain.c
) mcc -t mrank.m (producesmrank.c
) mcc -W main main mrank rank.m (producesmain_main.c
)
To compile and link all four C source code files (main.c
, rank.c
, mrank.c
, and main_main.c
) into a stand-alone application, use
mcc -m main_main.c main.c rank.c mrank.c
The resulting stand-alone application uses your customized version of mlfRank
rather than the default version of mlfRank
stored in the MATLAB Toolbox Library.
![]() | Alternative Ways of Compiling M-Files | Compiling mrank.m and rank.m as Helper Functions | ![]() |