I am trying to turn code written in Matlab into a standalone, compiled Matlab application. However, having received some odd errors, I realized that the code makes a lot of use of adding and removing from the path to circumvent the fact that several functions with the same name (but different results / calculations) are used several times. Looking around, I found that you can turn a folder into a package by placing a โ+โ in front of your name and going through and making sure that the functions in this package access each other using name_of_folder.name_of_function. This solves the namespace problem, but it potentially creates a lot of work, since I now need to go through and add the correct package to each function call (and I still have to duplicate a lot of files).
Then I saw a function import, and I hope this saves me some time. I think I can pass the package that I want one or two specific functions, these functions import the package, and then everything will work the way I want - if the functions called by these functions fall into the scope of this import statement . For example, if I installed something like
function foo(var1, var2, ..., packagename)
eval(sprintf('import %s.*', packagename));
...
bar1(var1, var2);
...
bar2(var2);
...
then I hope that bar1they bar2will use the package imported with the import statement. The documentation says that import instructions in conditional expressions and functions are limited to this code block, but I donโt know if this code block means only this text or โthis code blockโ is the code and everything that evaluates as a result. I have a feeling that this is the first, but I decided that I would ask in the hope that this was the last.
, ? , ?