Reputation: 3384
I am experiencing some problem while calling a method from matlab package because that method is calling another method of same package. In script I call method by specifying name of package which contains the method and call to this method works fine. However when method inside package try to call other method of same package then code crashes. Structure of my package is like this:
+pkg\methodA
+pkg\methodB
function methodA ()
methodB()
end
function methodB ()
disp ('Hello')
end
In methodA when I call methodB, I am not specifying the package name prior to method name. I want to check whether this implementation is incorrect or I am missing something.
Is this correct way of calling methodB:
function methodA ()
pkg.methodB()
end
Error message:
Undefined function or variable 'methodB'.
Error in pkg.methodA (line 4)
methodB () ;
Upvotes: 2
Views: 452
Reputation: 36710
You have to use the package name as a prefix in each function call (pkg.methodB()
) or you have to import pkg
using import pkg.*
.
Possible implementations are:
function methodA ()
pkg.methodB()
end
.
function methodA ()
import pkg.*
methodB()
end
Upvotes: 2