LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert an element into a 2D array and write the data into a spreadsheet

Solved!
Go to solution

Hello application engineers,

 

I am doing a project that uses multiple data acquisition devices, The  acquired data must be sorted and then write into a spreadsheet as needed. I prepared a program similar to the one attached here below.  The program used two random number generators, 0 and 1, to produce data simulating the two data acquisition process. I want to get all number grater than 0.5 from generator 0 and all number greater than 0.75 from another generator 1. Once the first generator find the first number greater than 0.5 then moves to the second generator to also find the first number greater than 0.75. This process repeat continuously.    

 

I used a quotient & reminder function in a while loop to repeat the data generation and sorting process.  I want to insert the qualified numbers into a 2D array, it did not allow me to insert new numbers into the 2D array, I do not knot how to make it.  I also do not know if the numbers can be written into the spreadsheet properly as the format shows on the left of the program , but first I need to get new data inserted into a array using either insert-into-array or build array.

 

Please help?

Gu

 

 

 

 

 

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

I think it will be much easier to use an auto-indexing terminal (on the loop) and write to your spreadsheet file once at the end of the VI. You can even right-click the to make it a conditional terminal, meaning it will only include elements when accompanied by a True boolean.

0 Kudos
Message 2 of 5
(2,560 Views)

Hi Gregory,

 

Thank you for you suggestion. 

I searched for auto-indexing terminal posts on NI web and found a few and read through them all, however, I still  not able to insert the qualified new element into the 2D array. Could you please provide further help?

 

The auto index is easy if there is only one layer loop and case structure, it makes the situation more complicated to understand when using it in multiple layers.

 

Regards,

Gu 

0 Kudos
Message 3 of 5
(2,537 Views)
Solution
Accepted by topic author edmonton

It sounds to me that your sets of numbers (used to populate the array rows) may be (or possibly "are almost sure to be") of different sizes.  In a multi-dimension Array, all Rows, Columns, Pages, etc. must be the same size.  If they are not, LabVIEW will "fill in the blanks" with default values to "make it so".

 

An easy way to see this is to create a blank 2D Numeric Array on the Front Panel.  Expand it by dragging the lower right corner down and right so you have 4 or 5 rows and columns.  Now put a number in cell 2, 2 -- notices the Array fill in with 0's (the numeric Default) to the left and above to make a rectangular Array of mostly 0's.

 

Think again if this is what you really want to do.

 

Bob Schor

0 Kudos
Message 4 of 5
(2,523 Views)

Hi Bob

 

I appreciate your reply.

I changed program structure to parallel loops for different devices and made coding much easier, only need to build 1D array. So, the issue is resolved.

 

Regards,

Gu 

0 Kudos
Message 5 of 5
(2,515 Views)