LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save a 4D Array in a File and load it later on?

Solved!
Go to solution

Hello,

 

I am trying to save a 4D Array (Array[4000] [3] [20] [5]) of UINT in a File. I can do it through "write in binary File". But then I can´t load it. I know I can transform my Array down to 1D Array of 1.200.000 Elements (4000*3*20*5) of UINT. When I load it, I have to transform it back (with a lot of "for-looping") back to 4D. But is there an easier way of doing that?

 

I was not able to find a solution in this forum - I am sorry if I made a new thread if there is already a solution in this forum.

 

Best regards

 

LabVIEW 2011
0 Kudos
Message 1 of 3
(3,618 Views)
Solution
Accepted by topic author Serdj

Use Reshape Array.  It is expandable to as many dimensions as you need.  First convert the 4D array to 1D to write the data to the file.  After reading the 1D array from the file, use Reshape again to restore the 4D format.

 

The Write to Binary File will accept any data format.  The Read Binary File will read data from any file.  If you tell it what the data format is, it will interpret it for you.  It works for me for a small test 4D array.  Read the detailed help for more information.

 

Lynn

0 Kudos
Message 2 of 3
(3,616 Views)

As Lynn said, there should be no extra code required.

 

When writing, make sure that "prepend size" is true (true is default) and when reading, wire an empty 4D array of the correct representation to the "data type" input.

 

(I also assume that your LabVIEW version is not extremely ancient)

0 Kudos
Message 3 of 3
(3,612 Views)