LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i read in chunks of data from an array

Hi

I have a file with 2 columns of data. I append this data into an array.I do this about 5 times.

Now I wish to read column 0 and 2 from the array 5 times.

How can i do this?


Thank you.
0 Kudos
Message 1 of 10
(3,676 Views)
Hi

I think after reading your file, you have a 2-dimensional array.

One way, if you just want to extract a column, is to use the Index Array-Function.

If you wire the 2d-array, you have two other inputs to specify which index you want (row- or columnbased). So just wire the input for columns and you get the data of column x as a one-dimensional array.

I don't know if this solves your problem - but if it doesn't, give us some more information to understand your problem a little bit better.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 10
(3,667 Views)
Hi

Let me describe the array that I have.

0 0 0
1 0 1.5
. . .
. . .
. . . First run
. . .
. . .
. . .
0 0 0


Second run -maybe different length


etc ............
0 Kudos
Message 3 of 10
(3,652 Views)
Hi

The length of a column doesn't matter if you use the function mentioned earlier to extract the whole column.

Have a look at the vi attached. First I generate a 2D-array (0-10 rows, 5 columns) and afterwards I extract the columns 0 and 2.

Hope it helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 4 of 10
(3,646 Views)
Hi

Maybe I have not made myself clear. Say column 0 contains 10 shots each of equal length, say 10 numbers long. I want to extract this data and take an average of these 10 shots.Similarly for column 2.

Can you please help?
0 Kudos
Message 5 of 10
(3,628 Views)
Hi Tuds

So, if I understand correctly, you have x columns with 10 rows (each row for a shot) and 10 pages (each for one number), what means you are working with a 3-dimensional array. Is this correct?

If I'm right, just have a look at the vi from my previous reply. You could use it in the same way for a 3d-array. If you wire a 3d-array, you get connectors for page, row and column. So if you wire row and column, you get the values at column x and row y of each page.

So you could wire e.g. a 0 at column and loop over all rows.

Is this what you are looking for?

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 6 of 10
(3,626 Views)
Hi again

I will outline exactly what i want to do.

Say for example ,column 0 has 10 runs each containing 10 points.

I want to take run1 and run2 and add them together. Then take the addition of run1 and run2 and add it with run3. I want to do this for the ten shots and then find the average.

How do you do this?
0 Kudos
Message 7 of 10
(3,624 Views)
Hi

I attach you a vi with the solution I would use.

First I just generate a 3dimensional array to simulate your datastructure.

Afterwards I add all runs in a for-loop.

Just have a look.

Hope it helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 8 of 10
(3,622 Views)
Hi

Thanks for that.

But I am reading the data from a file, say for 10 shots and appending it to an array. I am reading the data from the vi,readfromspreadsheet.vi which gives me a 2d array. I do I implement your solution from this?

Thanks.
0 Kudos
Message 9 of 10
(3,615 Views)
Sorry, but I'm a little confused now about your shots and runs.

What exactly do you have in your 2d array? Which dimension represents what? How many files do you read?

Maybe one of those files with description could help.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 10 of 10
(3,603 Views)