# How can I read matlab export as a multi-dimensional array?

I have exported the E-field resulting from a simulation into a matlab file (call it myresult.mat). For this, I have created a pipeline that gets the fields from a simulation and then I have attached an exporter.

When I load myresult.mat in matlab I get the following variables:

• Axis0, Axis1, Axis2 with shape1x11 values per axis. These are the Cartesian grid axis
• Snapshot0 with shape 1000,3. These are the 3 components of my field at the cell center of the Cartesian grid

I would like to reshape my flat list of values (i.e. Snapshot0) into a 4d array such that each dimension represents a component and the spatial axis, i.e. Snapshot0[c,i,j,k] where c is an index to the field component and i,j,k are indices to the discretization of space.

P.

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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.88761556,"math_prob":0.975557,"size":747,"snap":"2023-40-2023-50","text_gpt3_token_len":179,"char_repetition_ratio":0.1076716,"word_repetition_ratio":0.0,"special_character_ratio":0.23694779,"punctuation_ratio":0.13496932,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9978108,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-02T15:21:09Z\",\"WARC-Record-ID\":\"<urn:uuid:7475a6cc-00a8-409c-a671-21aff764438c>\",\"Content-Length\":\"43453\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e86e31be-5f3e-40fe-8f69-6d0a1a1fdd77>\",\"WARC-Concurrent-To\":\"<urn:uuid:2ff9ead2-e99b-463b-875d-33c1c7fe843c>\",\"WARC-IP-Address\":\"64.226.118.2\",\"WARC-Target-URI\":\"https://forum.zmt.swiss/topic/17/how-can-i-read-matlab-export-as-a-multi-dimensional-array\",\"WARC-Payload-Digest\":\"sha1:AXWB3AS6KZEX3QQDBLIKXBQ5EAAMOPFK\",\"WARC-Block-Digest\":\"sha1:RZJ3IHPNJDCLGA6DUXN3DFSTANVAFVJD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233511000.99_warc_CC-MAIN-20231002132844-20231002162844-00775.warc.gz\"}"}