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: 

replace array subset

Hi,

 

     I wonder is there a way to replace a subset of array without using local variable? Please see my labview vi. Thanks!

 

     Tom

 

 

0 Kudos
Message 1 of 15
(3,409 Views)

 

The replace array should work on any wire which is an array type regardless of its sink or source.

 

You image gives me the impression that you have to name all of your buffers like you have to do in text based languages. In LV the wire IS the buffer and ther is no need to put it a named widget. Just make LabVIEW do all of that dirty work and "let the data flow".

 

If you want to refine your question, please post the code where you are suing this contruct and someone will advise.

 

Have fun!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 15
(3,401 Views)
Take a look at the "Replace Array Subset" function on the Array pallete.
0 Kudos
Message 3 of 15
(3,400 Views)

Hi,

 

     Thanks for reply. All the examples that I found is that there is one input for original array and one output for modified array. If I only need to keep one array (output array is input array)  is there a way to do it without using local variable or shift register? I know with in place element and shift register I can avoid the copy of the data and achieve what I want. I just wonder is there a simple way to do it for a simple function like it?

 

 

 

     
0 Kudos
Message 4 of 15
(3,375 Views)

If you dont want to use any local variables, why are you opposed to using a shift register?

That sounds like the best choice to me.

Cory K
Message 5 of 15
(3,368 Views)

tom_z wrote:

I just wonder is there a simple way to do it for a simple function like it?


A shift register IS a very simple and basic tool. It IS the simple way. 😄

 

Message 6 of 15
(3,365 Views)

tom_z wrote:

Hi,

 

     Thanks for reply. All the examples that I found is that there is one input for original array and one output for modified array. If I only need to keep one array (output array is input array)  is there a way to do it without using local variable or shift register? I know with in place element and shift register I can avoid the copy of the data and achieve what I want. I just wonder is there a simple way to do it for a simple function like it?

 

 

 

     

 

Those examples are for illustration purposes so you can see the before and after.

 

You could chain a dozen of those together one after the other and they will all operate on the buffer represented by the input wire.

 

All wires need at least one sorce and one sink. You seem to be OK with using the control as a source so what type of sink would you like that is not a lofcal or a shift register?

 

You could wire the array to a For loop, is that an acceptable sink?

 

Try it for yourself! put a probe on the wire coming in and going out to the For loop and you will see that the data in the wire actual got replaced.

 

Just trying to help,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 15
(3,359 Views)

tom_z wrote:

All the examples that I found is that there is one input for original array and one output for modified array. If I only need to keep one array (output array is input array)  is there a way to do it without using local variable or shift register?


Also read Ben's answer once more. A pair of shift registers is a single memory location. That's what you wanted!

 

Don't think of controls and indicators as "variables", they are not. They are just access points that contain their own data copy and stick out to the front panel so you can interact with the code. Of course you can abuse controls and indicators as "variables" and access them via locals, but that's not their primary purpose in life.

 

Here is some easy reading.

 

In a more advanced implementation, you could also keep your data in an action engine.

 

Message 8 of 15
(3,357 Views)
Hi,

      Thanks all for your reply. I guess I have to use shift register. The problem is that I already have too many shift registers even with cluster them and this one is only used at couple of places. I just feel there may be a better solution than shift register for a simple function like this.

       I can't use function global or Action Engine because the subvi will be instantiated for multiple copies. You can make the function global reentrant by passing the function global vi reference but I have to keep passing another wire.
0 Kudos
Message 9 of 15
(3,346 Views)

Hi Ben,

 

I know the wire carries the data. If I want my source to be  my sink without using local variable or property node in labview it can't be achieved (at least I don't know).  In text programming you only need write x(i) = x(i) + 1 but here it seems more complex than that. I know the purpose of control and indicator but sometime there are variables only used for programming purpose and not are on front panel. It seems to me these variable have to be either control or indictor are unnecessary. It will make programming easier for such variable can be both source and sink without introducing data copy. I know it doesn't fit well with labview wire data flow but sometime you have to pass a wire through all over the place to pass the value is really not a nice thing to do.

 

0 Kudos
Message 10 of 15
(3,329 Views)