11-20-2012 10:48 AM
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.
Solved! Go to Solution.
11-20-2012 10:58 AM
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.
11-20-2012 11:04 AM
So to index out the second column, I 'index array' with the column index equal to 0, or 1?
11-20-2012 11:08 AM
@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
11-20-2012 11:22 AM - edited 11-20-2012 11:22 AM
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.
11-20-2012 11:28 AM
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?
11-20-2012 11:42 AM
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.
11-20-2012 11:57 AM
Can you post some actual sample data? That would help in making sense of this thing.
11-20-2012 12:26 PM
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.
11-20-2012 12:28 PM
That's what I was wondering. Glad you got it working.