I discovered another problem with the matlab compiler (version 3, which is included with Matlab 6.5), namely that it will not translate an m-file to c-code when that m-file tries to read a variable from a mat-file.
Mathworks does specify that one of the things that is not supported by the compiler (see here) are m-files that dynamically name variables to be loaded or saved. They give this example which is disallowed by the compiler:
x= 'f';
load('foo.mat',x);
However, this function also will not compile:
function testload(cfg);
b = load(cfg.filename);
c = getfield(b, 'a');
disp(c);
giving the following error
>> mcc -m testload
testload.c: In function `Mtestload':
testload.c:103: error: `mlxLoadStruct' undeclared (first use in this function)
testload.c:103: error: (Each undeclared identifier is reported only once
testload.c:103: error: for each function it appears in.)
mbuild: compile of 'testload.c' failed.
If I slightly rewrite the function it does work. The alternative function that has the desired functionality and that does compile correctly is
function testload(cfg);
filename = cfg.filename;
b = load(filename);
c = getfield(b, 'a');
disp(c);
At least this gives me a handle on how to modify my code with little effort to make it compatible with the Matlab compiler.