| MATLAB Compiler | ![]() |
Main File Wrapper
The -W main option generates wrappers that are suitable for building stand-alone applications. These POSIX-compliant main wrappers accept strings from the POSIX shell and return a status code. They pass these command line strings to the M-file function(s) as MATLAB strings. They are meant to translate "command-like" M-files into POSIX main applications.
POSIX Main Wrapper
Consider this M-file, sample.m.
You can compile sample.m into a POSIX main application. If you call sample from MATLAB, you get
If you compile sample.m and call it from the DOS shell, you get
The difference between the MATLAB and DOS/UNIX environments is the handling of the return value. In MATLAB, the return value is handled by printing its value; in the DOS/UNIX shell, the return value is handled as the return status code. When you compile a function into a POSIX main application, the first return value from the function is coerced to a scalar and returned to the POSIX shell.
| Using Wrapper Files | C Library Wrapper | ![]() |
© 1994-2005 The MathWorks, Inc.