If you have both software installed on the same computer, the easiest way would be to use matlab command. This means that you simply need to modify your code to something like this:
script in Lumerical = matlab("script in MATLAB");
but please bare in mind that you will not get any error message in Lumerical Script File Editor neither in MATLAB if you have any errors in your script.
The output from the MATLAB commands will be printed at the Lumerical script prompt. One limitation of the matlab function is that no error reporting is provided to either the Lumerical script prompt or the MATLAB prompt. MATLAB commands should be tested by typing them directly into the MATLAB prompt before they are called from a Lumerical script. The output buffer length is roughly 1e5 characters. Additional output will be truncated.
matlabget and matlabput are useful commands to use as well.
I also modified your code to be used in Lumerical for you review:
# Clear all data
l = 6e-6;
w = 6e-6;
p = 0.8e-6; # Periodicity of the Si disk (0.8 micron)
# Get the coordinate of hexagonal array with center x and y = 0.
Since I didn’t have MATLAB on my computer I couldn’t open the .mat file or check the commands. My apologies if you find any error in my code.