What you are looking for a way to make objects persistent between mex calls. See here (edited):
Yes, you can make a C++ object persistent between calls, and you don't have to return the pointer to the Matlab workspace. Simply define your object above the mexFunction entry point. It will remain persistent as long as your mex file stays in memory (i.e. you don't clear the mex file).