Same script in a path folder and the current folder. Which takes priority? (2024a, Ubuntu)
25 views (last 30 days)
Show older comments
ルーベン ルイス
on 29 Dec 2024 at 7:35
I have an .m file (class) on a folder which was added to the matlab path. On a separate folder, I have another .m file with the same class but I am making some changes and tests to it. Hence the matlab woking folder is the second one.
In windows or macosx, the priority is for the local folder. So when I try to run static methods in my class, it will run the methods from the .m file in the local folder. However, in linux (Ubuntu), the priority is given to the .m file in the matlab path and I am unable to test my newly changed script.
Is there a way to have the behavior in linux match the behavior in windows or macosx?
Thanks in advance for any assistance.
0 Comments
Accepted Answer
Walter Roberson
on 29 Dec 2024 at 8:12
3. Nested functions within the current function
4. Local functions within the current file
6. Private functions
7. Object functions. An object function accepts a particular class of object in its input argument list. When there are multiple object functions with the same name, MATLAB checks the classes of the input arguments to determine which function to use.
8. Class constructors in @-folders
10. Functions in the current folder
11. Functions elsewhere on the path, in order of appearance
Now, static methods are not object functions (I think), so we need to ask whether these classes are defined in an @ folder or not; if so then that @ folder has priority. If not, then "functions in current folder" has priority over "functions elsewhere on the path"
... on the other hand, the bit about "when there are multiple object functions with the same name" could be construed as implying that if the method name is unique that input arguments are not checked, in which case possibly uniquely-named static functions are classed as object functions ?
In no case should the function on the path (that is not a @ directory) get priority over the local folder.
However... if you happen to load the class on the path, and then cd to a different directory that defines the same class, it is possible that the old class definition will be retained until you "clear classes" or "clear" the specific class.
3 Comments
Walter Roberson
on 30 Dec 2024 at 5:43
Is it only the static methods that is the problem or is it also the non-static methods?
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!