I am using MATLAB 5.0 on Sun Sparc with Sun OS 4 and call some MEX routines, which are actually in a dinamically linked library. What I am trying to do is to have two MEX functions which are connected by some global variables. The first function initializes the vars, the 2nd one uses them. There are 2 separate calls from MATLAB to each routine. It seems that contents of the global vars are lost after the first call so that when the 2nd functiona attempts to use them it gets garbage. Looks like the library is loaded to and then unloaded from the memory each time it is called. Is there a way around this? Should that be an option for compiler (the MEX funs are written in C and compiled using acc), for MATLAB or for something else?