07-13-2017 10:08 AM
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
Solved! Go to Solution.
07-13-2017 10:23 AM
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.
07-13-2017 10:29 AM
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.
07-13-2017 12:21 PM
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.
07-13-2017 12:22 PM
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.
07-13-2017 12:30 PM
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 ^^
07-13-2017 12:37 PM - edited 07-13-2017 12:48 PM
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.
07-13-2017 01:04 PM
You are awesome brother, it's working, that's what I like 🙂
07-13-2017 01:13 PM
@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?
07-13-2017 01:15 PM - edited 07-13-2017 01:28 PM
@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.
(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.
(And if the analysis would slow down the loop, use a queue, enqueue in the case structure, and analyze it in a parallel loop)