Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Function preceding order within a deployed application
Replies: 2   Last Post: Apr 30, 2013 7:19 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,845
Registered: 7/26/08
Function preceding order within a deployed application
Posted: Apr 24, 2013 6:46 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I would like to know if the following specification
http://www.mathworks.fr/fr/help/matlab/matlab_prog/function-precedence-order.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 non-deployed 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/function-precedence-order.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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.