Hi I'm currently coding in MATLAB and C. I have compiled MATLAB functions into a C shared library using MATLAB Compiler (mcc), and called the functions in the shared library in a C++ program.
Can a global variable be declared to share data between MATLAB functions when called in C++?
To be exact, if there is a function matlabA()
and function matlabB()
in matlab, and is compiled into c++ shared library using mcc compiler as cppA()
and cppB()
, can I share a variable between them just by declaring variables as global in matlabA()
and matlabB()
?
It doesn't appear to work, then how can I share variable between functions?
Thanks!
MATLAB
function matlabA()
global foo
foo = 1;
end
function matlabB()
global foo
foo
end
C++
cppA();
cppB();