MATLAB Answers

Call function in package from package

39 views (last 30 days)
How I can use use function present in package from the package? If i have package with:
I would that in fun1.m i can call fun2.m. I only could call fun2.m with mypkg.fun2? There are some alternative?


Sign in to comment.

Accepted Answer

Sayan Saha
Sayan Saha on 11 May 2018
According to the documentation
all references to functions in the package must use the package name prefix, unless you import the package. See the example in the following link for importing package functions:


covariant_cat on 5 Jun 2018
I'd say that this is a very bad design since why should the code within a package depend on the package's name? What if I want to change the package name in the future (or put some of the code to another package)? Don't I have to modify every function in the package in that case?
Related questions:
Dariusz Borkowski
Dariusz Borkowski on 6 Dec 2019
I agree, this design is bad. It makes simple things impossible to do. It should be changed!

Sign in to comment.

More Answers (0)

Sign in to answer this question.