When I understand correctly, such code causes too much overhead for your functions:
function out = calculate(in)
persistent p_isdeployed
if isempty(p_isdeployed)
p_isdeployed = isdeployed();
end
...
if p_isdeployed
coder.xxx...
end
Such code will be rather slow, if you repeatedly clear the persistent variable e.g. by a clear all or clear function. But if you omit such inefficient cleanups, the overhead should be very small. Except if the actual calculation is tiny, e.g. out = in + 1 and you call this function billions of times. In this case Joan Puig's suggestion is the only usable way: Either accept the overhead for testing the deploy-status inside the function, or use two different functions.
I'm using both methods for the equivalent case that code should run efficiently under Matlab 2009a and 6.5: If the functions are large and the overhead of testing can be neglected, I test the version by the fast C-Mex FEX: isMatlabVer: if isMatlabVer('>=', 7, 9)
a = bsxfun(@plus, b, c)
else
a = b(:, ones(1, length(c)) + c;
end
If the overhead for testing the version would be too large (a rare case!), I create two functions, which are stored in different folders:
C:\MFiles\Matlab6.5\myfunc.m
C:\MFiles\Matlab7.9\myfunc.m
Then the function which initializes my toolboxes the matching folder is included in the path dynamically by addpath. Of course this methods will lead to an exploding complexity, if all other versions between 6.5 and 2012.b have to be considered, when this is implemented naively, but in your case you need only two folders: \myTools_deployed and \myTools_undeployed.