LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to average every certain lines in a 2D array

For example, if I have a 1000 by 300 2-D array and I want to average every 3 lines in this array to make it a 1000 by 100 array. How can I do this? Thanks!
0 Kudos
Message 1 of 10
(4,224 Views)

Hi,

     Use Delete from array,specify the dimension to it and then average.

0 Kudos
Message 2 of 10
(4,221 Views)
Decimate the array into 3 arrays.  You may or may not need to transpose it before that depending on the layout of your rows.  Add the 3 arrays together.  Divide by 3.
0 Kudos
Message 3 of 10
(4,219 Views)

Decimate only works for 1D array, so this needs a bit more work. Still, it should not be too difficult. 🙂


scoccer wrote:
For example, if I have a 1000 by 300 2-D array and I want to average every 3 lines in this array to make it a 1000 by 100 array. How can I do this? Thanks!

Is a "line" a column or a row?

 

(And no AutoTEX, "delete from array" makes no sense at all for this.)

0 Kudos
Message 4 of 10
(4,214 Views)

Sorry I am not familiar with arrays, do I need to use a loop or something like reshape array to make it a 1d array to use the decimate? Thanks!

 

In  this example,  a "line" is a column.

0 Kudos
Message 5 of 10
(4,210 Views)

Hi 

 

Check the attachments

 

Regards,
Santhosh M
Download All
0 Kudos
Message 6 of 10
(4,206 Views)

OK, here's a simple way to do this (LabVIEW 8.0)

 

Message Edited by altenbach on 11-03-2008 09:05 PM
Download All
Message 7 of 10
(4,178 Views)

Santhosh M wrote:

 

This is extremely inefficient, because the array in the shift register changes constantly, forcing new memory allocations with every iteration. This will be orders of magnitudes slower than a solution that operates in-place.

 

I would strongly recommend against this solution. 🙂

 

0 Kudos
Message 8 of 10
(4,173 Views)

altenbach wrote:

OK, here's a simple way to do this (LabVIEW 8.0)

 

Message Edited by altenbach on 11-03-2008 09:05 PM

That's exactly what I was thinking, except I didn't realize the decimate array wouldn't work on the 2-D array, and I wasn't on a LV computer at the time to work up the example.

Message 9 of 10
(4,140 Views)
Thanks very much for all your advices. It works great!
0 Kudos
Message 10 of 10
(4,135 Views)