User`s guide
5 Controlling Code Generation
5-22
The Compiler processes the string arguments passed to the main() function
and sends them into the compiled M-function as strings.
For example, consider this M-file,
sample.m.
function y = sample( varargin )
varargin{:}
y = 0;
You can compile sample.m into a POSIX main application. If you call sample
from MATLAB, you get
sample hello world
ans =
hello
ans =
world
ans =
0
If you compile sample.m and call it from the DOS shell, you get
C:\> sample hello world
ans =
hello
ans =
world
C:\>
The difference between the M ATLAB 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
is returned to the POSIX shell.