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: 

How to build Build 2D array using Replace Array Subset

Hi guys,

 

I know how to build array using shift register and build array function. I heard that it is slower to do it this way.

 

So I would like to ask how do I build a 2D array to store my data side by side with Replace array Subset, is it possible to do it without shift register?

 

program.png

case.png

result.png

 

 

Thanks!!!

0 Kudos
Message 1 of 5
(2,422 Views)

Hi guys,

 

Can you also tell me why is some number combination skip and how do I solve it.

program1.png

program result.png

You see after 90 0 why is 100 0 not store but it jump to 100 50

0 Kudos
Message 2 of 5
(2,417 Views)

Nextal wrote:

So I would like to ask how do I build a 2D array to store my data side by side with Replace array Subset, is it possible to do it without shift register?


You need a shift register (or feedback node) to retain the modified array from iteration to iteration. Unless you see this, you are not understanding shift registers yet.


@Nextal wrote:

I know how to build array using shift register and build array function. I heard that it is slower to do it this way.



Don't just repeat what you heard, try to understand the reasoning. Building arrays requires occasional memory allocations, a relatively expensive operation.

 

In order to user "replace array subset", you need to know the final size of the array and initialize the shift register with it. You could fill it with e.g. NaN to distiguish it from the data you have added. Since the array is allocated exactly once and never changes, it will be more efficient, especially if you are dealing with very large arrays. For small arrays like in your example it does not really matter what you use.

 


@Nextal wrote:

Can you also tell me why is some number combination skip and how do I solve it.


The code does exactly what you program it to do. If you want help, you need to attach the actual VI. We cannot run a picture and we cannot tell what is in the other cases of the case structure, for example. A picture never gives the full story.

 

Do some probing or run in highlight execution mode to see how the code arrives at the result. This should give you enough clues to repair it.

0 Kudos
Message 3 of 5
(2,403 Views)

Hi Altenbach,

 

Thanks for your reply. I think I had understand it. Can you help me with a motor program which I had been trying to debug it for a few days but I cannot find the problem at http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Help-to-fix-the-repeated-angle-problem-SMC100... ?

 

 

0 Kudos
Message 4 of 5
(2,394 Views)

Here is a 60 second rewrite. See if this works better for you. Still seems overly complicated.

0 Kudos
Message 5 of 5
(2,381 Views)