How to extract data from matrix for calculations in Lumerical Script

    • megan.obrien


      I have calculated and saved to a text file the data for both neffTM and neffTE for varying fill factor of a grating coupler. I want to load this data into another Lumerical script and use it for calculating the different pitch values required.

      The lines of code I have used to load the textfile into the script is as follows:

      M = readdata("textfile.txt");

      And the data is then loaded as a [17,3] matrix called M into the script workspace. I need to access the 2nd and 3rd columns for the pitch calculations, as te 2nd column is the neffTM values and the 3rd column is the neffTE values.

      However, I am failing to access them as it is. Can anyone help me out please?


    • Guilin Sun
      Ansys Employee

      Here is an intro about matrix

      Since this is a 2D matrix, you can access it as



      where n is the index for fill factor., eg, n=1

      you have the first value of the fill factor M(1,1); and neffTM and neffTE are the correspodent neff for this fill factor.

      Please try and compare your original data.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.