01-25-2010 11:17 AM
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.
Solved! Go to Solution.
01-25-2010 11:28 AM - edited 01-25-2010 11:28 AM
Get the first column then subtract it from the 2D array.
Easiest done when transposed because of autoindexing behavior. Here's an example.
01-25-2010 11:44 AM - edited 01-25-2010 11:46 AM
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...
01-25-2010 12:48 PM
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,
1
2
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!
01-25-2010 01:00 PM - edited 01-25-2010 01:01 PM
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: