Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Analysis & Postprocessing
  4. Exporting data to Matlab: how to access the data as a volume matrix

Exporting data to Matlab: how to access the data as a volume matrix

Scheduled Pinned Locked Moved Analysis & Postprocessing
6 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SylvainS Offline
    SylvainS Offline
    Sylvain
    ZMT
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hank_H
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hank_H
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • L Offline
          L Offline
          lsc
          wrote on last edited by
          #4

          Dear Sylvain,

          I have some trouble understanding why we have to put the -1 and why all the exported data do not have the same size.
          Do you have an explanation maybe ?

          Thanks a lot !

          1 Reply Last reply
          0
          • SylvainS Offline
            SylvainS Offline
            Sylvain
            ZMT
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lsc
              wrote on last edited by
              #6

              Hi,

              Thanks for this answer ! I get it now :)

              Best,
              Léa

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Search