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: 9,040
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

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');
rehash path;
fun1 = @subfun;
fun = functions(fun1);

%% Second path
path2 = locpath('subfolder2');
rehash path;
fun2 = @subfun;
fun = functions(fun2);


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();
root = fileparts(mfilename('fullpath'));
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
subfun in folder 1 call
subfun in folder 2 call

When running wth stand alone deployed application I get this.

C:\Somewhere> foo.exe

subfun in folder 2 call
subfun in folder 2 call

There is no way to shadow subfun in subfolder2. Is there any work around?


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

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.