Dear @visvas

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
clear;
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.
if (mod(floor(l/p),2)==0){
no_points=floor(l/p)-1;
}else{
no_points=floor(l/p);
}
floor(w/(sqrt(3)/2*p));
if (mod(floor(w/(sqrt(3)/2*p)),2)==0){
no_rows=floor(w/(sqrt(3)/2*p))-1;
}else{
no_rows=floor(w/(sqrt(3)/2*p));
}
x=matrix(no_rows,no_points);
y=matrix(no_rows,no_points);
for (i=1:no_rows)
{
for (j=1:no_points)
{
x(i,j)=((no_points-1)/2-(j-1));
y(i,j)=((no_rows-1)/2-(i-1));
}
}
for (i=1:no_rows)
{
if (mod(floor(no_rows/2)+1,2)==0){
if(mod(i,2)==0){
x(i,1:no_points)=x(i,1:no_points)*p;
}
else{
x(i,1:no_points)=x(i,1:no_points)*p+p/2;
}
}
else {
if(mod(i,2)==0){
x(i,1:no_points)=x(i,1:no_points)*p+p/2*ones(1,no_points);
}
else{
x(i,1:no_points)=x(i,1:no_points)*p;
}
}
}
y=y*sqrt(3)/2*p;
#matlabput(x,y);
#matlab("plot(x,y,'*')");
addpoly;
V=[x,y];
set("vertices",V);
set("name","random_polygon");
set("z span",1e-6);
```

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.

Thanks