03-16-2016 08:18 AM
Hi,
I would like to insert a while loop inside a for loop. In particular I would like to identify N subarray from an INPUT using a for loop. Then, for each subarry, I would to identify a particular vale of the subarry using a while loop. Then, once that this vause has been identified, the for loop should run with the second iteration. It would be possible to do something like the example attached? Many thanks, Davide
03-16-2016 08:46 AM - edited 03-16-2016 08:52 AM
first, yes you can put loops in loops (e.g. while- inside of for-loops or vice-versa)
i cleaned up your "example" a little
it is not clear what you really want to do,
please be a little more pseudocodish,
or explicit in what inputs and what is the output you want.
<edit>
NOTE that with the small values (0 to 1) from random .. the while loop never leaves the first iteration
and no meaningful output exists, except that maybe the while- or for-loop stops (for sensible values in input array)
</edit>
03-16-2016 09:04 AM
Hi jwscs,
many thanks for your replay.
My input is1 column file (.txt). This represents a pressure time hystory of about 100 seconds. Due to the fact that I have an individual event each 10 seconds, I would like to identify before these 10 subarray (i.e. 10 events). Then, for each of them, I would like to identify a particular value inside each event. When this is identified by the while loop, I would like to stop the while lope and to save this stop value in a file (.txt) using write file. Therefor I would obtain a final .txt file with these 10 values (while the input could be given by 1000 data). Consequently, when the first output value (realted to the first subarry) is identified, the while loop should stop and it should start again the second while loop (related to the second subarray) in order to identify and to save the second value of the output. And go on....I don't know if I was clear. Thanks, davide
03-16-2016 09:13 AM
Please below the sketch.
03-16-2016 09:22 AM - edited 03-16-2016 09:31 AM
please split you text more (pseudocodish)
what is the criteria for the "particular value"?
for saving the "particular value" you can make a conditional indexed output
i made a better example
now it even ends 😉
<edit>
the conditional auto-indexing is superfluous,
sine the loop stops when something is "found", Tunnel-Mode should be "last-value",
and then the "conctenating" a "auto-indexing"
03-16-2016 09:41 AM
Please tell me that someone else put that bit of code in your while loop and not you.
(I needed to post this exact same reply on someone else's message last week.)
03-16-2016 09:52 AM - edited 03-16-2016 09:53 AM
mhh .. as you might have seen .. i got other things on my mind 😉
it is also superfluous,
was reimplementing without thinking
interesting thread all the same .. thx
03-16-2016 10:15 AM
Hi,
the criteria about the particular value is: if (i+1)>10(i), then it is ture (i.ie if the value of i+1 is, at least, 10 times i).
In other words, I have an INPUT of 1000 data points. I want to identify 10 windows of 100 data points each. For each window I want to identify just 1 value (with criteria above) and to save this true value. Then my output should be a .txt file with 10 values (one for each window identified using the for loop). Many thanks, davide
03-16-2016 10:50 AM - edited 03-16-2016 10:53 AM
i think that should do it
replace/add your data source and output
BTW you can drag and drop the snippet onto a Block-Diagram window
sorry RESULT holds the value whos predecessor is at least 10 times smaller
03-16-2016 11:05 AM
Many thanks!! It is working!! wowowowowow 🙂