LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting and Searching 2D array from DAQ

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(2,513 Views)
Solution
Accepted by jtrout13

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.


GCentral
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
0 Kudos
Message 2 of 10
(2,511 Views)

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

0 Kudos
Message 3 of 10
(2,507 Views)

@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

 


GCentral
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
0 Kudos
Message 4 of 10
(2,504 Views)

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.

0 Kudos
Message 5 of 10
(2,501 Views)

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?


GCentral
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
0 Kudos
Message 6 of 10
(2,497 Views)

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.

 

BD.JPG

0 Kudos
Message 7 of 10
(2,492 Views)

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


GCentral
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
0 Kudos
Message 8 of 10
(2,480 Views)

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.

0 Kudos
Message 9 of 10
(2,475 Views)

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


GCentral
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
0 Kudos
Message 10 of 10
(2,471 Views)