Photonics

Photonics

Topics related to Lumerical and more.

Issue in 2D colour map data export in matlab

TAGGED: ,

    • sagar
      Subscriber

      I have found this issue while exporting 2D colour plot through Matlab script. The pattern is changing the orientation. I think there is some error in generated Matlab script for 2D colour map. Here is the difference in the same images shown in Lumerical and after exporting through Matlab. 

    • Guilin Sun
      Ansys Employee

      I would suggest to check the matrix dimensions to identify which one is for Height or lambda. You can dirfectly plot the numbers (eg, use 1:N_height and 1:N_lambda) to plot, wherer N_ is the dimension length. Please check the command from matlab as different command may arrange the data differently.

      Usually if you save the dataset from Lumerical to .mat then in matlab the read the data as it is.  Since this is 3rd party tool it is hard for us to check for it.

       

    • sagar
      Subscriber

       

      The left side was plotted from Lumerical and the right side was plotted by Matlab after extracting sweep data from Lumerical. You can see along with the orientation of the axis of the graph; there are issue in the whole images, the coloured lines are bent. How to resolve this issue. This time I copied the data from numerical and plotted by Matlab.

    • Guilin Sun
      Ansys Employee

      Yes, obviously.

      Lumerical monitor records actually the frequency, not the wavelength by default. So the wavelength is not equi-spaced if you did not specify equi-wavelength. Lumerical script can know it is frequency or wavelengh in plot. However the matlab does not know this. So it assumes the wavelength is equi-spaced. Please either

      1: plot in frequency

      2: interpolate the result with equi-wavelength spacing before exporting to Matlab, or set to record equi-wavelength in the monitor and redo the sweep. It is better to inteploate the result.

    • Simenew Assefa
      Subscriber

      How can I export FDTD viualized image to Matlab Image?

    • Simenew Assefa
      Subscriber

      It say could not open a connection Matlab, you must have asupported version of maatlab installed to usi this version feature. Please the manual for this detail.

    • Guilin Sun
      Ansys Employee

      The MATLAB script integration feature requires MATLAB version 2006b to 2019a. The following links might be helpful:

      MATLAB script integration configuration guide

      MATLAB - Lumerical integrations

      MATLAB script integration

      Creating vector plots with MATLAB

       

       

    • xuanlunhuang20
      Subscriber

      For the orientation of the figures, you need to make sure that which dimension of your result matrix corresponds to height and which to lambda. You might need “transponse” function in Lumerical or “axis xy” and “flipud” function in MATLAB.


      For the problem of inconsistency between two figures, you might need these codes, which is answered by Dr. Sun in my previous post: (This is just an example, you can change it according to your needs)


      E2=getelectric(“monitor”);#get your result
      x=getdata(“monitor”,“x”)
      y=getdata(“monitor”,“y”);
      mx=100;#x points in matlab
      my=50; #y points in matlab
      xmatlab=linspace(min(x),max(x),mx);
      ymatlab=linspace(min(y),max(y),my);
      E2matlab=interp(E2,x,y,xmatlab,ymatlab);#interpolation


      Because the “image” function in Lumerical will change the axis space automatically, the axis space in MATLAB does not equal to that in Lumerical. This leads to the inconsistency between two images.

    • Guilin Sun
      Ansys Employee

      Hi @xuanlunhuang20, thank you for help!

      Lumerical script uses the mesh point values, whereas Matlab re-interpolates the axis to equal spacing. therefore distortion occurs. 

Viewing 8 reply threads
  • The topic ‘Issue in 2D colour map data export in matlab’ is closed to new replies.