LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete from multiple rows elements from Array

I have an array that contains about 3700 rows, and 4 columns. Every 37 rows a cycle of data begins. I would like to delete the first row of every cycle of data (i.e. row 1, row 38, row 75, row 111, etc -- until I have deleted every 37th row in the entire array). Then if possible I would like to take an average of rows 2 through 37, 39 through 74, 76 through 110, etc...

Any help would be greatly appreciated.
0 Kudos
Message 1 of 8
(5,187 Views)
Hi,

I would suggest you to use the delete from array function here, you can wire the 2-D array to it and just wire the raw number that you want to delete, this will delete the raw completely; you can then put this in a for loop to do it for every raw that you need to delete.

For the averaging of certain raws I would use the array subset VI to get the portion that you are interensted in and then use the mean VI to calculate the average.

I hope this helps,

Regards,

Juan Carlos
N.I.
Message 2 of 8
(5,187 Views)
Thanks for the help. I have tried using the delete from array function, and placing it in a for loop, however, when I look at my output, I get a new array everytime. How do I create my loop so that once I delete a row that I will feed the array (with the deleted row) back into the loop, so that I progessively delete one row at a time until I have the array I would like.

Thanks again.
0 Kudos
Message 3 of 8
(5,187 Views)
The solution is to use a shift register to pass the value between iterations of the loop; take a look at this piece of code, generates an array of numbers and then deletes half of the raws. Let me know if this helps,

Regards,

Juan Carlos
N.I.
0 Kudos
Message 4 of 8
(5,187 Views)
Just one warning on the Delete From Array function: every time you call it, LabView rewrites the entire array. Your array is not tiny (3700 rows, 4 columns). To delete every 37th row, you're rewriting the array 100 times. If the array was really big, that would take a long time.
Instead of deleting rows, it would be more efficient to create a new array. Initialize the new array to the full size (3700 by 4), then use Array Subset to grab 36-by-4 pieces of the original array (skipping the rows you want to "delete") and use Replace Array Subset to write it to the new array. Your program will be even more efficient if you never have to display the array, but if you need to, when you're done building the new array, write it to a local variable for the original
array.
Are you sure that you really need to delete rows? In your calculation of averages, you can just skip the rows you don't want to include. What else will you do with the array besides calculate some averages?
0 Kudos
Message 5 of 8
(5,187 Views)
> I have an array that contains about 3700 rows, and 4 columns. Every
> 37 rows a cycle of data begins. I would like to delete the first row
> of every cycle of data (i.e. row 1, row 38, row 75, row 111, etc --
> until I have deleted every 37th row in the entire array). Then if
> possible I would like to take an average of rows 2 through 37, 39
> through 74, 76 through 110, etc...
>

One thing you don't mention is what the array is used for afterwards.
It is displayed, written to file, are the averages written back to those
deleted rows?

The reason I mention this is that it may make sense to loop through just
indexing out rows and using mod 37 math on the iteration count "i",
either add it to the running sum, or output the average. You can then
just
skip the row that you don't want to use if you don't need the array
afterwards. You can also use this same approach to move the data to a
preallocated array using replace.

Greg McKaske
0 Kudos
Message 6 of 8
(5,187 Views)
Greg,

I have decided to delete the rows by excluding all data that is out of range (determined be a percentage calculation) -- which was probably harder in the long run, but it works perfectly for what I am doing.

After I modify the arrrays, I am displaying them both in lab view (in multiple different graphs and a table), and then also using active X to transfer the data to Excel (where is will be re-arranged and plotted accordingly).

I indeally need to get an average of the points in the array about every 36 rows, and then display this, since I am looking to track the output decay over time. If you have any suggestions as how I might find and average of every x number of rows in an array, and either input these into another array or a table, that
would be greatly appreciated.

Thanks,
Travis
0 Kudos
Message 7 of 8
(5,187 Views)
> After I modify the arrrays, I am displaying them both in lab view (in
> multiple different graphs and a table), and then also using active X
> to transfer the data to Excel (where is will be re-arranged and
> plotted accordingly).
>
> I indeally need to get an average of the points in the array about
> every 36 rows, and then display this, since I am looking to track the
> output decay over time. If you have any suggestions as how I might
> find and average of every x number of rows in an array, and either
> input these into another array or a table, that would be greatly
> appreciated.
>

I can't see the original post about the data shape, but if you have a 2D
array, wire it into a For loop. Use i mod 36 equals 0 to select whether
you
add the array to the current total in the shift register, or whether
you divide the total array by 36 and append it to the averages array,
then overwrite the total to restart the process. If the rows isn't
doesn't contain an integer multiple of 36 rows, you need to deal with
the excess data either ignoring or making an average with a different
denominator. I'd assume you do this outside the loop.

Greg McKaskle
0 Kudos
Message 8 of 8
(5,187 Views)