Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Function preceding order within a deployed application
Posted:
Apr 24, 2013 6:46 AM


I would like to know if the following specification http://www.mathworks.fr/fr/help/matlab/matlab_prog/functionprecedenceorder.html
is applied for deployed code (using MATLAB compiler) as well?
On my test, the "Functions in the current folder" does not seem to shadow the hononyme function(s) for deployed application.
I would like to find a mechanism of shadowing function (as with nondeployed matlab) for deployed application, which works well under the compiler 2006B.
I don't find any relevant doc on the subject, beside Loren's blog (not quite a official reference spec to me).
Here is a minima example code, which comprises 3 files ./foo.m, ./subfolder1/subfun.m and ./subfolder2/subfun.m
function foo(varargin) % function foo(varargin) % mcc C m foo.m a subfolder1/subfun.m a subfolder2/subfun.m % Minima example to illustrate the 'Function preceding order' document % http://www.mathworks.fr/fr/help/matlab/matlab_prog/functionprecedenceorder.html % is not applicable in deployed code (2013A)
%% First path path1 = locpath('subfolder1'); cd(path1); addpath(path1,'begin'); rehash path; fun1 = @subfun; fun = functions(fun1); disp(fun.file); feval(fun1);
%% Second path path2 = locpath('subfolder2'); cd(path2); addpath(path2,'begin'); rehash path; fun2 = @subfun; fun = functions(fun2); disp(fun.file); feval(fun2);
cd(locpath('')); rmpath(path1); rmpath(path2);
input('foo>> Type CR to quit: ', 's' );
end % foo
%% function path = locpath(relpath) % local function declared and used by in foo.m % return the absolute path from the relative path if isdeployed() root = ctfroot(); else root = fileparts(mfilename('fullpath')); end path = [root filesep() relpath]; end % locpath
%% function subfun( ) % subfun( ) % A dummy function located in subfolder1/subfun fprintf('subfun in folder 1 call\n'); end % subfun
%% function subfun( ) % subfun( ) % A dummy function located in subfolder2/subfun fprintf('subfun in folder 2 call\n'); end % subfun
%%%%%%%%%%%%%% If I run under MATLAB, I get this output:
>> foo C:\Somewhere\subfolder1\subfun.m subfun in folder 1 call C:\Somewhere\subfolder2\subfun.m subfun in folder 2 call
When running wth stand alone deployed application I get this.
C:\Somewhere> foo.exe
C:\Somewhere\foo_mcr\subfolder2\subfun.m subfun in folder 2 call C:\Somewhere\foo_mcr\subfolder2\subfun.m subfun in folder 2 call
There is no way to shadow subfun in subfolder2. Is there any work around?
Bruno



