Consider the following case:
A main python file calls three different MATLAB functions -- func_initialize.m, func_1.m and func_2.m.
func_initialize take some arguments from the Python workspace, and creates a list of global variables: aa, bb and cc. These variables are then used in func_1 and func_2.
func_initialize is structured as follows:
global aa bb cc
However, within the python script, when I call these functions from the workspace dictionary:
eng = matlab.engine.start_matlab()
it gives me the following error:
File /usr/local/MATLAB/R2019a/toolbox/matlab/external/engines/engine_api/+matlab/+internal/+engine/getVariable.m, line 27, in getVariable
Undefined variable 'aa'.
What's wrong with the programming logic? Could there be a better way to share data between the three MATLAB files?
In my actual code, a Python object has some methods which call these three MATLAB functions. MATLAB engine is started by the class constructor. Then the class methods use this MATLAB engine to call various functions and access the variable names.