This page shows how to create a vector plot of rectilinear data from Lumerical's software using MATLAB.
MATLAB uses a different convention for plotting matrix data than Lumerical. To get the same figure orientation in MATLAB as in your Lumerical plots, you will need to define a uniform grid for the spatial vectors, x, y, z. This can be done in MATLAB or in Lumerical's scripting environment; however, since MATLAB's convention for creating meshgrids is different from Lumerical's convention, it is a lot easier to do this in Lumerical's scripting environment before exporting the data to MATLAB. Let us assume we have the fields from a monitor named "monitor" in FDTD:
FDTD post processing step
# Get field and position vectors Ex=getdata("monitor","Ex"); Ey=getdata("monitor","Ey"); Ez=getdata("monitor","Ez"); x=getdata("monitor","x"); y=getdata("monitor","y"); z=getdata("monitor","z"); # Choose a frequency point ( the first one ) Ex=pinch(Ex,4,1); Ey=pinch(Ey,4,1); Ez=pinch(Ez,4,1); # Specify the resolution of the plot res_x=10; res_y=10; res_z=3; # Define uniform vectors x2=linspace(x(1),x(length(x)),res_x); y2=linspace(y(1),y(length(y)),res_y); z2=linspace(z(1),z(length(z)),res_z); xmesh = meshgrid3dx(x2,y2,z2); ymesh = meshgrid3dy(x2,y2,z2); zmesh = meshgrid3dz(x2,y2,z2); # Interpolate fields on new uniform vectors Ex=interp(Ex, x, y, z, x2, y2, z2); Ey=interp(Ey, x, y, z, x2, y2, z2); Ez=interp(Ez, x, y, z, x2, y2, z2); matlabsave("monitor_data",Ex,Ey,Ez,xmesh,ymesh,zmesh);
Once the 3d uniform grids have been created, we can either plot them in Lumerical's scripting environment or load the data file in MATLAB and plot them in MATLAB.
Lumerical script to generate vector plot
E = rectilineardataset("E",x2,y2,z2); E.addattribute("E",Ex,Ey,Ez); vectorplot(E);
MATLAB script to generate same plot
MATLAB - Lumerical integrations
Creating 2D image plots with MATLAB
Creating vector plots with MATLAB
Creating 3D visualizations with MATLAB