## Saturday, April 20, 2013

### What to do if all the MATLAB licenses in your institute are occupied ?

Quite often it happens that when I try to run my MATLAB script that uses a certain toolbox of MATLAB, it gives me the following error:

 License checkout failed.
Maximum number of users for Communication_Toolbox reached.
Try again later.
To see a list of current users use the lmstat utility or contact your
Troubleshoot this issue by visiting:
http://www.mathworks.com/support/lme/R2012a/4  

This shows that all the licenses for the Communication Toolbox are in use by other people in your company/institution, and you will have to wait until one of them releases the license. It can be a painstaking job to keep executing the same script again and again in the hope of getting the license for yourself. This repeated execution of the script can be automated using the try, catch block.

Suppose, myscript.m is the script you want to run. You can use the following script to keep trying until someone releases a license for you.

 close all;clear all; clc;
errcl = 2;
while errcl~=1
try
errcl = 1;
myscript;
catch err
disp('Licenses are still not available ...Retrying after two seconds ...');
pause(2);
errcl = 2;
end
end


In order to break the loop, press Ctrl+C for a few seconds.
You can also change the time between the two tries by changing the argument of pause(2) function from 2 to any number of seconds you desire.