Index of Single Element in a DataSet
This type of scheme is used when fine control is required when accessing a DataSet. It is also the most intuitive method of accessing the elements.
nearField[1][1][1][1].EFieldComp1 = nearField[1][1][1][1].EFieldComp1 * 2
The previous command multiplies the value at the first frequency, at the first indexed point in space. By iterating through all of the axes, it is possible to selectively modify specific values based on the index of the axes. In the following example, all fields further than from the Z axis is set to 0. Save the script as modNF_indiv.lua for use in future examples.
-- Create the near field dataset nf = pf.NearField.GetDataSet("Horn.StandardConfiguration1.NearField1") for freq = 1, #nf.Axes[1] do for xPos = 1, #nf.Axes[2] do for yPos = 1, #nf.Axes[3] do for zPos = 1, #nf.Axes[4] do if ( math.sqrt(nf.Axes[2][xPos]^2 + nf.Axes[3][yPos]^2) >= 0.15 ) then nfPoint = nf[freq][xPos][yPos][zPos]; nfPoint.EFieldComp1 = 0 + 0*i nfPoint.EFieldComp2 = 0 + 0*i nfPoint.EFieldComp3 = 0 + 0*i nfPoint.HFieldComp1 = 0 + 0*i nfPoint.HFieldComp2 = 0 + 0*i nfPoint.HFieldComp3 = 0 + 0*i end end end end end return nf