Why do I receive a warning when trying to compile XLSREAD using MATLAB Compiler 3.0 (R13)?
3 views (last 30 days)
Show older comments
Why do I receive the warning "The "which" function is only available in MEX mode. A run-time error will occur if this code is executed in stand-alone mode." when I try to compile XLSREAD from MATLAB?
When I tried to compile the following function:
function getin;
[a b]=xlsread('test11.xls')
return
using the command:
mcc -m -B sgl getin.m
it resulted in the following warning:
Warning: File: C:\MATLAB6p1\toolbox\matlab\iofun\xlsread.m Line: 68 Column: 16
The "which" function is only available in MEX mode. A run-time error will occur if this code is
executed in stand-alone mode.
and the compiled getin.exe did not run. Is there a possibility to include functions such as XLSREAD into standalone applications?
Accepted Answer
MathWorks Support Team
on 19 Apr 2012
MATLAB Compiler 3.0 (R13) cannot compile some built-in MATLAB functions (such as WHICH) and objects.
NOTE: As it stands, the XLSREAD function is not compilable. You can modify it slightly so that it can be compiled:
1. Comment out line 64 which reads:
if exist(filename,'file') ~= 2, error('File not found'); end
2. Comment out line 68 which reads:
filename = which(filename);
and replace it with:
filename = [pwd '\' filename];
3. Save the modified version with a unique name (so that the original is not lost) to the following directory where XLSREAD is located:
$MATLAB\toolbox\matlab\iofun
(where $MATLAB is your root MATLAB directory)
4. Issue the following command at the MATLAB prompt:
rehash toolboxcache
You should now be able to call the modified version of XLSREAD in your code and compile it without any issues. As a side effect to allowing the function to be compiled, some error catching is lost. Please make sure that the .xls file to be read is in the same local directory as the generated executable.
Make sure that if you decide to modify any of the functions that are shipped with MATLAB, you save it with a different name so that you do not lose the original.
0 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!