02-10-2014 12:02 AM
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 .
02-10-2014 12:50 AM - edited 02-10-2014 12:51 AM
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.
02-10-2014
12:53 AM
- last edited on
01-10-2025
01:49 PM
by
Content Cleaner
Hi @nk
That's because you have set "Use default if unwired" on the output tunnel of the Case Structure.
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.
Here is the link for more information about auto-indexing with conditional tunnel: https://www.ni.com/docs/en-US/bundle/labview/page/conditionally-writing-values-to-loop-output-tunnel...
Ee Lim
02-10-2014 12:55 AM
@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.
02-10-2014
01:08 AM
- last edited on
01-10-2025
01:51 PM
by
Content Cleaner
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:
https://www.ni.com/docs/en-US/bundle/labview/page/passing-one-value-to-the-next-loop-iteration.html
Ee Lim
02-10-2014 01:18 AM - edited 02-10-2014 02:23 AM
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....)