Exporting data to Matlab: how to access the data as a volume matrix
-
When you load the exported file into Matlab you will see at least four variables, namely Axis0, Axis1, Axis2 and Snapshot0. The array with data is in the latter but shaped as N x 3, where N is the number of point samples .
In Matlab, you can reshape the Snapshot0 quantity in the following way.
- For cell-centered data with 3 components (e.g. Electric field E(x,y,z)):
E = reshape(Snapshot0, [length(Axis0)-1, length(Axis1)-1, length(Axis2)-1, 3)
which you can then use as:
E[i,j,k,c]
where c is an index to the field component and i,j,k are indices to the discretization of space.
- For point data with 1 component (e.g. Vector potential V(x,y,z)):
V = reshape(Snapshot0, [length(Axis0), length(Axis1), length(Axis2))
which you can then use as:
V[i,j,k]
where i,j,k are indices to the discretization of space.
-
hi,
Internally, the way physical quantities (e.g. E, H, V, etc...) are discretised on different grids/meshes is dictated by the numeral method being used -- with the FDTD method, for example, results are more accurate if E and H are discretised differently. At post processing, typically in the "Sensor Extractor", the data are interpolated either on the nodes of the main grid or at the centres of each cell (this can be changed by ticking a box in the Sensor Extractor, but the default is usually what gives the best accuracy). When interpolating results in cell centres, the size of the data is "-1" in each direction, compared with when results are interpolated at the nodes (i.e. corners) of each cell.
Does that make sense?best