LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array operation--Offset value

Solved!
Go to solution

Hi all,

 

I would like to offset my DAQ data. Could any one of you help me on this? Thank you.

 

2D array is my DAQ data 

 

1 1 1 1 1

2 2 2 2 2

3 3 3 3 3

4 4 4 4 4

 

I would like average the first 5 data points as offset values. I finished this part and I got 1D offset array

1

2

3

4

 

The function I would like to relize is to minus the offset values from the data array. 

 

1 1 1 1 1                   1 1 1 1 1

2 2 2 2 2                   2 2 2 2 2

3 3 3 3 3      Minus     3 3 3 3 3

4 4 4 4 4                   4 4 4 4 4 

 

Is this possible, should  I expand the 1D array to  2D array before do the calculation? Thanks.

 

0 Kudos
Message 1 of 5
(4,366 Views)
Solution
Accepted by topic author oly

Get the first column then subtract it from the 2D array.

 

Easiest done when transposed because of autoindexing behavior. Here's an example. 

 

 

Message Edited by altenbach on 01-25-2010 09:28 AM
0 Kudos
Message 2 of 5
(4,358 Views)

I don't understand what you are trying to do..

 

What do you mean about the offset values?

If you take the average of the first row:

 

1

2

3

4

 

You get 2.5.

 

Do you want to reduce the 2D array by a value of 2.5?

 

so you get...

 

-1.5

-0.5

0.5

1.5

 

When you say:  

 

 

1 1 1 1 1                   1 1 1 1 1

2 2 2 2 2                   2 2 2 2 2

3 3 3 3 3      Minus     3 3 3 3 3

4 4 4 4 4                   4 4 4 4 4

 

 

Is it a one-to-one relationship ie Array1[i,0] - Array2[i,j], which would give you:

 

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

 

???

 

 

EDIT SECTION:  was talking with a co-worker and finally hit the send button.

Just noticed Altenbach's answer... 

Message Edited by Ray.R on 01-25-2010 12:46 PM
0 Kudos
Message 3 of 5
(4,350 Views)

Thanks to all! I am trying to explain my question  a little bit more clear. 

 

As for offset value, for the example above,

 

1 1 1 1 1

2 2 2 2 2

3 3 3 3 3

4 4 4 4 4

 

I will take the first 5 data points and average them, let's say, for the first row, I got (1+1+1+1+1)/5=1. That is channel 1. For  the second row, I got (2+2+2+2+2)/5=2 for channel 2. 

 

Then I got a 1D offset array for 5 channels,

 

3
4

 

I already finished this part. 

 

Then I want every point in each channel minus this offset value.  For channel 1, offset value is 1, then I want every point 1,1,1,1,1 in the first row minus this offset value. so I will get 0 0 0 0 0 for the first row.

 

And the final array I got will be 

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0 

0 0 0 0 0

 

I am studying the program  alterbach gave. It seems to me that I need make some changes. Anyway,

 

Thank you!

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 4 of 5
(4,330 Views)

Well, it would really help to use example number that are less degenerate. 😉

 

Anyway, to take each row and subtract its mean, you could do the following:

 

 

 

 

Message Edited by altenbach on 01-25-2010 11:01 AM
Message 5 of 5
(4,322 Views)