LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to store data in 2D array

Good morning,
we have problem how to store data(scalar numbers)in 2D array. The data will be loaded in 2 FOR nested cycles(one for row index, the second for column index), we have problem, that one of indexes(row, or column) must have property DISABLED INDEx, which makes us worry.
 
 
 
0 Kudos
Message 1 of 12
(10,879 Views)

Your question is not clear at all.

The array functions accept all kinds of arrays in their bottom inputs, so for a 2D array the same function can sometime accept no index, one index or two. It is true that on some occasion the functions will only accept certain kinds of inputs.

My guess would be that you're trying to use Insert Into Array and it's not working for you, so here's the easy way of solving this. When you output a wire from a for loop, it builds an array by default, like this:

The other alternative is initializing the array before the loop and then passing it through the loop using shift registers and using Replace Array Subset.


___________________
Try to take over the world!
0 Kudos
Message 2 of 12
(10,871 Views)


 
The other alternative is initializing the array before the loop and then passing it through the loop using shift registers and using Replace Array Subset.
 
This is what I meant to, but I don't know how to do it.
 
We found one solution, but it has one great problem, using Build Array function where output is fed back to the input we create dynamically vector, that is growing, but we must turn the program off after each measurement, to delete data stored in this vector.
 
That idea with statically allocated array is shown in figure.
We tried to use Array Init and Replace Array Subset functions
 
I can send you a sample program, as long as this forum doesn't allow me to enclose files.
Please send me your  mail address, if you have any other questions.
Ivan
0 Kudos
Message 3 of 12
(10,858 Views)
The forum software does allow attachments, both VIs and images (as you can see in my previous post). Make sure you don't preview the post before posting, or you lose the attachment.

___________________
Try to take over the world!
0 Kudos
Message 4 of 12
(10,853 Views)

this is only an idea...

I don't know how to make it working



Message Edited by om1air on 07-15-2008 06:26 AM
0 Kudos
Message 5 of 12
(10,851 Views)
0 Kudos
Message 6 of 12
(10,848 Views)

We can't see that image because it's on your hard drive.

Under the Submit Post button there is an attachment field where you can browse for a file and then it will be uploaded with your post. You don't have to embed it.


___________________
Try to take over the world!
0 Kudos
Message 7 of 12
(10,845 Views)
0 Kudos
Message 8 of 12
(10,826 Views)

Again, the easier solution would be to just index out the number, just like I showed in my previous example, and it will automatically build a 5x4 array.

If you still want to do it this way, the key item you're missing is a shift register. When you wire the 2D array into the Replace function, you're always wiring the same data you initialized. In order to keep your data between iterations, you will need to right click the wire and replace it with a shift register.

There are two reasons your code breaks, which you can see if you enable the context help window. The first is that you're wiring a 1D array into the index input. The second is that you're providing both a row and a column index for the replace, but then you provide a 1D array and LabVIEW doesn't know which direction to use when replacing.

To fix this you can either place the replace function inside the inner loop (with a shift register on that as well) or replace at a specific row and leave the column index unwired (which will replace at column 0).

But in any case, my original suggestion is usually the better solution.

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.


___________________
Try to take over the world!
0 Kudos
Message 9 of 12
(10,820 Views)
Many thanks for your time, tomorrow, I will try it, but the picture will help much more than thousand words.
Have a nice day.
Ivan
Message 10 of 12
(10,815 Views)