Restricting the port range used by matlab-proxy?

The find_port used by many most apps

port=$(find_port ${host})

really is just a convenience method defined by OOD to find an available, open, port number. You could do whatever you want here, defining a custom thing if you want as long as it produces an appropriate port number, but this function is really good as it checks if the port is in used, and will pick another if so.
Better yet, it already supports exactly what you ask for via optional argument 2 and 3:

port=$(find_port ${host} 6000 6010)

if you wish to have it limited to a just a few ports.

Documentation here:

edit: oh i just now noticed that the min_port and max_port default values can also be directly configured in the batch_connect yml

so i guess just do that instead of fiddling with the scripts.