LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving and writing multi-dimensions array with Binary File VI's

Solved!
Go to solution

Hello everybody,

 

I have a 3-D complex array (eventually it can have higher order) and I need to save and, using another VI, read this array. The solution I found here in the forum was use the Binary File VI's. 

 

Now I am having trouble to recover the N-dimentional array after I open with the Read Binary File VI. The output array have the correct dimension, but all the information are concentred in only one dimension (as it was a 1-D array). 

I can't resize the array, because in the original aplications the sizes is not know a priori and also the original array have a lot of elements, so sometimes when I use the resize array VI, my computer doesn't have enough memory to complete the operation.

I synthesized how I am saving and reading in the VI attached here (LabVIEW 2015).

 

I hope anyone can help me.

Thank you all in advance

Frederico

0 Kudos
Message 1 of 5
(2,034 Views)

Hi Federico,

 

use "prepend array size" with the WriteBinaryFile function and let LabVIEW load your data automatically using this information!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,011 Views)

Hi GerdW

Thank you for your message!

 

Do you mean only change for True the input in the "prepend array" in Write Binary File VI?

It doesn't retourn the array I am expecting.

 

Regards

0 Kudos
Message 3 of 5
(1,995 Views)
Solution
Accepted by topic author freddearaujo

Hi Frederico,

 

prepending the array size allows you to read this information from your file - either on your own or have ReadBinaryFile do the work for you:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(1,988 Views)

Frederico,

     I've taken the liberty of rewriting your VI (using LabVIEW 2018, but I suspect the results will be similar in earlier versions).  I've simplified some of the steps by using defaults, didn't use some functions (like Deny Access, as I assumed you were not multi-tasking here), and used the Prepend Array Size so that LabVIEW would be able to reassemble the Array knowing the order and size of its dimensions.  By writing and testing a little Demo routine such as this, I was able to remind myself of some "facts" about multi-dimension Array I/O I had forgotten (I've rarely used more than 2 dimensions in an array).

     Here is my VI:

3D Complex Array Binary File I/O3D Complex Array Binary File I/O

The first part is essentially your code, but with the Prepend Array Size switch turned on.  Assuming there are no Errors, I re-open the file, ignore the file size, and tell it to read in a 3D Complex Array, namely the thing that I wrote!  And guess what -- it returns a 3D Array, which I then compare (using Equal?) and ensure that all of the (3-D array of) Booleans are True, meaning I read in an exact copy of the Array I wrote out.

 

Bob Schor

 

P.S. -- For a little more fun, try writing more than one 3D array, and then attempting to read them in "all at once" (instead of one-at-a-time).  Be sure to look at what comes out -- hint, it is not a 3D Array, and is also not a 4D Array (try to understand why NI/LabVIEW chose this reasonably-logical Data Structure for this output).

0 Kudos
Message 5 of 5
(1,974 Views)