From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding element to an array/buffer

this is probably a stupid question, but I can't figure out how to do this without using feedback loops. I'm still used to C or Java with a with the "new" command.

So I have made this array, which I call buffer. It's just an array of doubles.

I want to insert things into this buffer and clear it at certain times. Like when the buffer reaches a certain size.

In labview, to insert elements into the array, I have to give it an existing array. How do I do that and keep the old array without a feedback loop. Right now, to get it working, I'm passing an old buffer, using the insert array VI, passing out the new array. I have to wire the new array to the old array creating a feedback loop.

Is there another better way to do this? In c I would just call a new command command, and pass the memory pointer around in my functions performing modification on the array. How would I do this in labview?

Thanks
0 Kudos
Message 1 of 4
(8,689 Views)

Yes, you keep the array in a shift register or feedback node. This is the right way to do this. What makes you think that you need to do this without them?

Best is to allocate a fixed size array and then replace elements using "replace array subset". If you do it right, there will be exactly one copy of the array in memory and all operations will occur "in place".

(Note that operations such as "insert into array" and "delete from array" change the array size and thus  force a new copy in memory. So try to avoid these)


d1sturbanc3 wrote:
In labview, to insert elements into the array, I have to give it an existing array. How do I do that and keep the old array without a feedback loop. Right now, to get it working, I'm passing an old buffer, using the insert array VI, passing out the new array. I have to wire the new array to the old
Please attach a small sample of your program so we can see more clearly what you are trying to do here.
 
What is your LabVIEW version?
0 Kudos
Message 2 of 4
(8,677 Views)

hi, i want to extract certain elements from an array which satisfies a  true condition and put it into another array. I am not able to do it with shift registers. what is the other way using which i can achieve this

0 Kudos
Message 3 of 4
(5,076 Views)

Suggestion: Do not post your query to a thread that is way old even though if it is similar. It is always recommended to start a new thread with a right title that explains your problem (More info for start here)

 

Answer: Use Index array with the proper element index to extract data and insert into array to put those data into another array.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 4
(5,072 Views)