MATLAB: MATLAB compiler and superiorto

compilerMATLAB Compileroop

I have a piece of MATLAB code that I'm trying to compile into a standalone. The uncompiled version works fine, but when I compile it and run from a DOS command window, I encounter an error
Unknown class 'SeparableLinearOp' used in builtin function 'SUPERIORTO'
The call to superiorto is in the constructor of a second, old-style class. The class SeparableLinearOp is not being used, so I didn't provide code for it. Because SeparableLinearOp is not being used, the M-code version doesn't care about its absence. Why does the compiled version care?

Best Answer

After working with tech support, the problem seems to be resolved. Basically, if you call superiorto('ClassA','ClassB',...,'ClassZ'), then definitions for all those classes have to be in the CTF archive. However, as usual, the compilation process isn't always smart enough to know what to include in the archive and you have to force the inclusion of certain things with pragmas. This was the case for SeparableLinearOp, because it was never actually invoked. It just appeared within the list of string arguments to SUPERIORTO.
However, a more convenient solution than adding pragmas was to dynamically detect which classes were present and adjust the superiorto argument list accordingly:
inferiorClasses={'ClassA','ClassB',...,'ClassZ'};
oldclasses=cellfun(@(c) exist(['@' c],'dir'), inferiorClasses );
newclasses=cellfun(@(c) exist(c,'file'), inferiorClasses );
superiorto(inferiorClasses{oldclasses|newclasses});
It's a bit of a shame, of course, that SUPERIORTO can't just ignore undefined classes. It also would have saved some headache if exist(...,'class') worked on old style classes as well as new ones.