You could use a little detection here.  try:

echo "MATLAB_BIN=$(dirname $(which matlab))" > local.cfg