From: rudi_m on
Hi,

I'm a matlab beginner and want to create a standalone executable from a *.m file which returns unix-like 0 on success and !=0 on error.

For example I've tried:

function [retVal]=testFunc( )
reVal=1;
end

Then compiled with mcc and run:
$ ./testFunc
$ echo $?
0

hm, ...

I've read
http://www.mathworks.com/support/solutions/en/data/1-18448/?solution=1-18448
but unless I'm blind I can't see nothing about my question allthough that topic matches my question exactly.

Any Ideas?

cu,
Rudi
From: Walter Roberson on
rudi_m wrote:

> I'm a matlab beginner and want to create a standalone executable from a
> *.m file which returns unix-like 0 on success and !=0 on error.

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/br2cqa0-20.html

"Returned values from standalone applications will be 0 for successful
completion or a nonzero value otherwise"

This suggests to me that if you want to return a non-zero status, that
_possibly_ using a call to Matlab's error() routine might work.

See also

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f7-996707.html#f7-996914

which shows an example of calling a Matlab routine from a C main routine. The
shown C main routine ends with a return(0) C call, which you could alter at need.
From: rudi_m on
Thx, very helpful

> Walter Roberson wrote:
> http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/br2cqa0-20.html
> "Returned values from standalone applications will be 0 for successful
> completion or a nonzero value otherwise"

OK, no way to get the regular return value.

> This suggests to me that if you want to return a non-zero status, that
> _possibly_ using a call to Matlab's error() routine might work.

This works - just tested. Calling error() returns 255 to the shell. Thats what I need for now.

> See also
> http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/f7-996707.html#f7-996914
> which shows an example of calling a Matlab routine from a C main routine. The
> shown C main routine ends with a return(0) C call, which you could alter at need.

Didn't read that completely, but for sure this is the way to get more control.

thx a lot,
Rudi