LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add value only when true

hi I am making an array with the iteration values of for loop by chechking the conditions and i want it to be done only when my condition is true.

But now what is hapenning is that if the condition is false 0 is over wirrting my values.

 

And also i have put two for loops inside a for loop.

the second for loop is running to the first loop iterations.

 

thanks in advance

 I am adding the vi i have made .

@nk
Download All
0 Kudos
Message 1 of 6
(3,578 Views)

Ok, take a step back and try to explain what you are trying to do. Firstly, you did not attach the subVI.

 

What are the diimensions of the 3D array? If you are autoindexing you typically don't want to wire N of the FOR loop. (... and why are you not autoindexing on the innermost loop?)

 

Since you are NOT autoindexing on most output tunnels, you make a lot of effort, but only the last value actually counts.

 

Can you show a small 3D array containing typical data and then tell us how the output should look like? Currently, things don't make a lot of sense.

0 Kudos
Message 2 of 6
(3,561 Views)

Hi @nk

 

That's because you have set "Use default if unwired" on the output tunnel of the Case Structure.

 Capture.PNG

 

Hence if the condition is true, it will only output an array of only 1 iteration value at the output tunnel of the most inner For Loop

And if the condition is false, it will output an array with default value of 0 at the output tunnel of the most inner For Loop.

 

Also, it seems that 2nd For Loop does not have the auto-indexing feature enabled in the output tunnel, which only generate a 2D array, instead of 3D array in the Array 3 indicator. I wonder if generating 2D array output for the Array 3 indicator is what you want, but if you want to generate 3D array output, you should enable the auto-indexing feature for the 2nd For Loop.

 

And what you also should do is using the auto-indexing with conditional tunnel in the inner For Loop to automatically generate an array of iteration values if the elements in array is greater than the max value you've set as shown in the screenshot below for simple illustration.

Capture2.PNG

 

Here is the link for more information about auto-indexing with conditional tunnel: http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/condacc_valuesnloops/

 

 

Ee Lim



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



Message 3 of 6
(3,556 Views)

@ongeelim wrote:

Here is the link for more information about auto-indexing with conditional tunnel:...


He's using LabVIEW 2011, which does not have autoindexing tunnels.

0 Kudos
Message 4 of 6
(3,549 Views)

I see. That makes sense since he can't use the new feature. Thanks for pointing out.

 

Then perhaps in the same link that I've posted, he can use the left diagram in the link instead to get the same results.

That requires shift register and Build Array for the inner For Loop.

 

This links could be helpful in creating the shift register:

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/creating_shift_registers/

http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/shift_registers_concepts/

 

Ee Lim



See that button on the left side of this post...

If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~



0 Kudos
Message 5 of 6
(3,539 Views)

There are still way too many questions to really tell what the OP actaully wants. Why is he appending to the beginning of the arrray? (much less efficient!) What is contained in "arrray 2" when the VI starts? (if empty, an array diagram constant of I32 datatype would make more sense). Then we would also need shift registers across all loop boundaries.

 

He is also writing back to the "max" control, which does not do anything useful for the current run because it has already been read before the loop started. Whatever he actually wants, ther are probably much simpler ways to do it. 😄 (Maybe something like "threshold array" might prove useful....)

0 Kudos
Message 6 of 6
(3,524 Views)