Matlab compiler and Statistics toolbox - error when running standalone application

I am trying to compile a small function containing the nanmean function from the stats toolbox using the Matlab compiler. This does not work - it complains about an undefined function.
The function is simple:
function testNanmean
%#function nanmean
x = nanmean(randn(30))
and I compile it using
mcc -m testNanmean.m -d mexdir\
I install the MCR installer (C:\Program Files (x86)\MATLAB\R2014a\toolbox\compiler\deploy\win32\MCRInstaller.exe).
When I run the program I get the following output:
E:\Utvikling\WingFish\Matlab\mexdir>testNanmean.exe
Undefined function 'nanmean' for input arguments of type 'double'.
Error in testNanmean (line 4)
MATLAB:UndefinedFunction
Any idea on what is going wrong? And yes: The function works in Matlab. :-)
PS! The presence of the
%#function nanmean
line does not seem to change results.

2 Comments

I tried the above example on my system (32-bit R2014a) and the exe when run against the 32-bit MCR, seems to work fine. It's weird that the function works in MATLAB.
  1. Do you observe the above behavior with other Stats functions like nanmin, nanmax, etc, as well?
  2. Can you run the exe from inside MATLAB?
>> !testNanmean.exe
3. To rule out that your ctfroot is corrupted, I'd probably try recompiling with -C (capital C) flag so that when I run the exe, it extracts to the same folder.
The issue applies to the whole stats toolbox. I am finding that you can work round this by creating local copies of the toolbox files you need and adding those to the required files list.

Sign in to comment.

Answers (1)

I get this as well. It doesn't matter whether I run the exe from windows or from the Matlab prompt. I also find that the compiler pragma doesn't have any effect. The -C option doesn't change it.

Categories

Asked:

on 21 May 2014

Commented:

on 25 Jul 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!