Saving 2D Simulation Data to Matlab Correctly,,


#1

I was practicing with the examples available on Lumerical website. For saving 2D data (the example on the scripting page) it was straight forward to extract to Matlab and plot. Now applying that to the silver slab example (Bloch Boundary Conditions)
In Lumerical I just added towards the end of the provided sweep script (matlabsave(“T_final.mat”, theta,f); I got a file saved.

Back in Matlab;

load(‘T_final.mat’);
figure
imagesc(theta,f,‘Transmission’); axis xy;
colorbar;
c=colorbar;
c.Label.String = ‘Normalized Transmission’;
xlabel(‘Angle’);
ylabel(‘Frequency’);

I get in return a blank graph page with the following notice
Invalid datatype for Image CData. Numeric or logical matrix required for image CData.

Did I save it to start with wrong?? Or is something corrupted in my basic Matlab plotting code?
Thank you,


#2

This is mostly due to the fact that you only saved the data for theta and f, which are paramter variables. You did not save the data for resulting variable, say “Transmission”. If the transmission data is in Transmission , you can use
matlabsave(“T_final.mat”, theta,f,Transmission)

please try to see if you can get the correct plot.


#3

Thank you gsun I’ve saved the workspace and extracted the needed values to regenerate the plot in Matlab. Thanks a lot,