Importing classes in scripts vs functions
5 views (last 30 days)
Show older comments
I have a class file called auxFunctions.m, where several functions have been defined. When I import and call functions in the class file using the following syntax it works well:
import auxFunctions.*
[jointStruct,markerPlateStruct]=readInputSetupFile(setupFile);
However, when I try to do the same thing in a function that is called from another function I get this error:
Undefined function 'readInputSetupFile' for input arguments of type 'char'.
I put a break point on the the line that gives the error did the following K>> help readInputSetupFile readInputSetupFile
[jointStruct,markerPlateStruct]=readInputSetupFile(setupFileName) reads
the XML setup file ... (more details)
so it knows the function is there, however I cannot call it without putting auxFunctions.readInputSetupFile(setupFile).
I call many auxilary functions from this file and would like to use the short function calls, but I could not figure out how to make it work inside a nested function (it works in a script or in the main function). Does anyone know how I could do this, or do I just have to add in the auxFunctions.readInputSetupFile where ever I call the function?
Thank you!
4 Comments
Sean de Wolski
on 25 Apr 2014
Do you then try to use it inside of a conditional?
I guess does the simplest possible function work?
function foo
import
call imported
end
Importing is local to functions and to control statements which is why I ask:
Answers (0)
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) 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!