%http://www.mathworks.com/help/techdoc/ref/system.html
function_CALLER
%Ensure there is only one copy of matlab running in the machine before you
%start...
clc;
status = false;
nInstances = inf;
while(~status)
      [mem sV] = memory;
      display(['The max possible array size due to RAM is : ' ...
          num2str(round(mem.MaxPossibleArrayBytes/(1024*1024)))  ' MB'])
      [status,result] = system('matlabBatchScript.bat','-echo'); 
      while(nInstances > 1)
          [status1,result1] = system('tasklist /FI "imagename eq matlab.exe" /fo table /nh');
          nInstances = numel(strfind(result1, 'MATLAB.exe'));
          pause(1);
      end
end
end




