User`s guide
6 Standalone Applications
This command invokes mbuild to compile the resulting MATLAB Compiler
generated source files with the existing C source files (
mrankp.c and
main_for_lib.c) and link against the required libraries.
MATLAB Compiler provides two d ifferent versions of
mrankp.c in the
matlabroot/extern/examples/compi ler directory:
•
mrankp.c contains a POSIX-compliant m ain function. mrankp.c sends
its output to the standard output stream and gathers its input from the
standard input stream.
•
mrankwin.c contains a Windows version of mra nkp.c.
mrankp.c
Thecodeinmrankp.c calls mrank and outputs the values that mrank returns.
/*
* MRANKP.C
* "Posix" C main program
* Calls mlfMrank, obtained by using MCC to compile mrank.m.
*
* $Revision: 1.1.4.32.2.3 $
*
*/
#include <stdio.h>
#include <math.h>
#include "libPkg.h"
main( int argc, char **argv )
{
mxArray *N; /* Matrix containing n. */
mxArray *R = NULL; /* Result matrix. */
int n; /* Integer parameter from command line.*/
/* Get any command line parameter. */
if (argc >= 2) {
n = atoi(argv[1]);
} else {
n=12;
6-16