LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting few elements off array

Solved!
Go to solution

Hello,

 

i want to modify this VI. It has to delete for example 5 elements of an array, then take the next elements and delete the next 5 elements and so on.

What my VI does is, that I only delete the first 5 elements.

It has to look like this:  1 2 3 4 5 0 0 0 0 0 5 3 2 4 3 0 0 0 0 0 1 3 4 6 6.......If deleted, the zeros shouldn't exist-> 1 2 3 4 5 5 3 2 4 3 1 3 4 6 6

0 Kudos
Message 1 of 10
(3,444 Views)

You need to do another Delete from Array after you have done the first to get rid of the next group.  You probably want to do this in a loop and to have the code be flexible enough to delete any number of groups of zeroes at any given positions.

 

Search the forums.  I'm certain it's been asked dozens of times how to delete zeroes from an array.

Message 2 of 10
(3,430 Views)

Since it looks like you are not dealing with an array initially but acquiring data while trying to delete, it would be better to just not even add the data you do not want to the array.  Use a counter that resets after 10 iterations.  When the count is less than 5, you add the element to the array.  When the count is 5 to 9, you do nothing with the current data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 10
(3,422 Views)

With each iteration, you are growing the array by one element while trying to delete five. Makes no sense.

You are also adding the new element at the beginning of the array, which is very hard on the memory manager and thus very inefficient.

Do you have example code that is a bit more reasonable and more realistic? Once you do, I am sure we can find a solution easily.

Message 4 of 10
(3,393 Views)

Hmm, i never worked with this "count", or maybe you mean something else.

 

I thought, that I want this a little bit different.

-> I want to get 5 elements, delete these 5 elements and get new 5 elements.

My array for example: 1 2 3 4 5 -> deleted -> 2 4 5 3 1 -> deleted 3 4 5 2 3 ...

It can't be so hard, my brain just don't want to work.

0 Kudos
Message 5 of 10
(3,392 Views)

My main goal is to analyze this Heartrate. But the problem is that I got some "peaks" what I don't like to get in my measuremets. So I thought I analyze maybe 1000 elements of this heartrate, delete them and look forward for the next 1000 elements. But this comes later ^^

0 Kudos
Message 6 of 10
(3,387 Views)
Solution
Accepted by topic author Hasiman

Use a fixed size initialized array with 1000 elements in a shift register and overwrite from the beginning using replace array subset while keeping track of the insert point. When full, analyze the data and start replacing from the beginning again. Wash, Rinse, repeat.

 

There are also ptbypt tools that keep the last N points.

 

Message 7 of 10
(3,380 Views)

You are awesome brother, it's working, that's what I like 🙂

0 Kudos
Message 8 of 10
(3,361 Views)

@Hasiman wrote:

You are awesome brother, it's working, that's what I like 🙂


Based purely on your example, why not just use an Autoindexing output tunnel on the FOR loop?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 10
(3,354 Views)

@Hasiman wrote:

You are awesome brother, it's working, that's what I like 🙂


Your code makes absolutely no sense and probably belongs into the Rube Goldberg thread.

 

 CollectRube

 

(why is the zero in a shift register, it never changes. Why are you initializing a new array with each iteration of the FOR loop? The "data to analyze" could be wired to the upper shift register output and all lower code deleted without change in functionality... You are still prepending to the front, reversing the data. Why...?)

 

Here's what I had in mind earlier.

 

Collect1000

 

(And if the analysis would slow down the loop, use a queue, enqueue in the case structure, and analyze it in a parallel loop)

Download All
Message 10 of 10
(3,351 Views)