Ano Ano Posted June 6, 2016 Report Share Posted June 6, 2016 Hello, I have a 2D nth array, ie: 1 2 3 4 5 6 2 3 7 8 9 4 7 8 3 45 7 1 ... 2 5 1 8 1 5 I want to take the first three rows, add the elements together and create a new row that will replace the three rows and I want to do this every three rows and create a nth/3 2D array. Any ideas? Thank you in advance Quote Link to comment
Mads Posted June 6, 2016 Report Share Posted June 6, 2016 When you say that you want to add the first three rows and add the elements together I assume that the sum you are after is not the sum of all the elements in those rows (which would be just one number), but the sum of each subcolumn, or? If so, in your example above the first row in the output array will be: 10, 13, 13, 57, 21, 11 There are a lot of ways to do that, and the different ways have different speed and memory efficiency depending on how many columns there are, and how many rows you want to sum. Attached is one alternative (made in LV2015, back-converted to 2012) that seems to be an OK compromise between code simplicity and speed...I'm sure someone will take the challenge and improve it though ArrayNthRowSum.vi Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.