# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Splitting and Searching 2D array from DAQ

Hi,

I am collecting data from a DAQ which returns a 2-D array.  I'm taking 1000 samples at a time from 4 channels and I get returned a 2 column X 1000 row matrix:

The first column indicates the channel and the second column indicates the sample value.

I want to search this matrix for all the values corresponding to a given channel and plot them.

I.e. if the matrix looks like this:

1     54.5

2     42.4

3     67.6

4     15.2

1     34.2

2     22.5

...

I want to extract all the values in column 2 which have a value of 1 in the first column and plot them on one graph, and repeat for the values of column 1 equal to 2-4.

I can't figure out how to do this using array operations.

Message 1 of 10
(2,515 Views)
Solution
Accepted by topic author jtrout13

## Re: Splitting and Searching 2D array from DAQ

If the first column is always 1,2,3,4,1,2,3,4... then I would just index out the second column and use the Decimate 1D Array to split apart the different channel data arrays.  You will need to expand the Decimate 1D Array to 4 output elements.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 10
(2,513 Views)

## Re: Splitting and Searching 2D array from DAQ

So to index out the second column, I 'index array' with the column index equal to 0, or 1?

Message 3 of 10
(2,509 Views)

## Re: Splitting and Searching 2D array from DAQ

@jtrout13 wrote:

So to index out the second column, I 'index array' with the column index equal to 0, or 1?

Array indecies are 0 based.  So the second column is index 1

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 10
(2,506 Views)

## Re: Splitting and Searching 2D array from DAQ

This solution only results in me getting the same signal on all 4 channels.  The output array from the DAQ seems to be in random order with regard to what the first column value is.

Message 5 of 10
(2,503 Views)

## Re: Splitting and Searching 2D array from DAQ

Well, since the channels are somewhat random, you need to use a FOR loop.  What version of LabVIEW do you have?  Can you post what you have so far?

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(2,499 Views)

## Re: Splitting and Searching 2D array from DAQ

I have LV 8.5.  What I'm doing is taking 1000 samples for each channel on each iteration of the loop, then plotting them in order.  I'll eventually expand this to display an FFT spectrum as it changes dynamically for each channel.  I tested the below BD with only one channel hooked up, and the result is that all four plots show the signal that I'm putting into channel 1.  I don't understand why I need to index row 0 to get the signal out.  If I index the columns or index the row to 1, I don't get any signal output at all.

Message 7 of 10
(2,494 Views)

## Re: Splitting and Searching 2D array from DAQ

Can you post some actual sample data?  That would help in making sense of this thing.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 10
(2,482 Views)

## Re: Splitting and Searching 2D array from DAQ

Thanks for your help.  I resolved the problem... After looking at the sample data, it was not in the form the manufacturer said it would be in.  I was able to accomplish my purposes using the 'index array' function only.

Message 9 of 10
(2,477 Views)

## Re: Splitting and Searching 2D array from DAQ

That's what I was wondering.  Glad you got it working.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 10
(2,473 Views)