LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looping problem

I have an array of index locations from which I index two separate arrays. I then subtract the indexed array values, compare the subtracted value if it is greater than a preset I replace in one of the arrays a new value. How do I continue the comparison until it is false all the time making necessary replacements and incrementing both arrays after each true output. Right now LabVIEW goes through the entire array of index locations and performs this comparison once for each indexed point. Any suggestions/help is appreicated. Thanks
0 Kudos
Message 1 of 13
(4,338 Views)
I have gone through your bmp, from your description I'm still not clear what you want to do. Do you want to use an index for comparison more than once?
Message 2 of 13
(4,338 Views)
I have three arrays A, B, C. One is an array (A) of index locations that is specific to array B. Arrays B & C are suppose to be the same size but are not due to holes in the data in array B. These points in array A are where I need to begin filling in the data in array B. Initially arrays C & B are both indexed via array A, subtracted and then compared to a value. If greater than this value I insert into array B a corrected value. I then want to increment the index value once for both arrays B & C and to the same subtraction, comparison, replacement and continue doing this until the comparison is false.

Currently array A is indexed in it's entirety and the subtraction/comparison/replacement is performed at each individual location only once but this is
not good since there may be numerous holes that need filling. The other problem that I did not address was once I fill in the first data points, say three, then I need to add three to each subsequent value in array A to keep in step with where the original holes in the data are. My bmp file may be showing an additional array that I'm not talking about here but that one is not a problem.

I hope this explains better what I am trying to do, and I appreciate your help.

dld
0 Kudos
Message 3 of 13
(4,338 Views)
What is controlling number of times the For loop runs right now is the number of elements in Array A. It is possible to run the For loop more than once by putting it in a While loop. However, there will be a need to update Array A again with the remaining "holes." The best option would be to capture all the "holes" from the beginning. Is this dificult to do or does the update add additional "holes" to Array B?The other problem can be solved with a shift register (initialized to zero). You capture each data points and add it to the incoming Array A value.
0 Kudos
Message 4 of 13
(4,338 Views)
I can capture all of the hole locations, they reside in Array A, however, after I fill in the first hole the original hole locations, in Array A, from index 1 to the end will be off by whatever that number is obviously this will continue to be true until the program completes. I need to be able to use Array A using the first location, index 0, as my starting point, fill in the holes until the my comparison is false and add to every subsequent element in Array A the number that represents the holes filled. This will maintain the integrity of Array A that is pointing me to the holes that require filling. Updating Array B does not add additional holes, at least I don't think so, hopefully it is decreasing them until eventually both Arrays B &
C are the same size.

For what it's worth I can do this manually by capturing one hole location at a time filling in only one data point, saving to file and then recalling the file and go through it all over again. (it still won't fill in numerous holes at once, just one at a time) Problem is I have to keep manually running the program until all the holes are filled, which is not very good.
Thanks again, the help is much appreciated.
0 Kudos
Message 5 of 13
(4,338 Views)
Your comment helps and I think a programatic solution can be found. Right now to update Array B you use "Insert Into Array" function, I'm thinking that you should try "Replace Array Subset" function instead and check the results. The premise for this is your statements indicating shifts in indexes stored in Array A as a result of Array B update.
The part I'm yet to understand is the value of the shift. Assuming we have [2,5,8,11,12,...] as index to Array B stored in Array A. During Array B update, values originally in position 2 and above (i.e. 2,3,etc) would be moved one place (i.e. 3,4,etc) and new value will be put in position 2. That means Array A indexes will have to become [...,6,9,12,13,...] in order to be valid. The othe
r scenario is where you don't care what value is in position 2 and you just want to replace it. In this case the "Replace Array Subset" function will be the most appropriate and there will be no shifting.
0 Kudos
Message 6 of 13
(4,338 Views)
I will try the Replace Array Subset and see if that solves the problem in that version of the code. I took several approaches in trying to solve the problem, one of them is the code I posted as the bmp file that you and I are discussing. I wrote another program entirely, which overwrote the file I originally read from, however, I had to run it manually after each iteration which was not efficient enough. I rewrote that program, removed the write to spreasheet vi, inserted a while loop with shift registers, downstream of the initial read from file, (also added additional code), and it appears to work although I have to test further using larger data sets. What it essentially does is attack one "hole" at a time. I've elimi
nated Array A, the while loop searches through Array B each time, inserting missing data points based on particular criteria, and does not stop until all the "holes" are filled. I don't have a lot of experience with LabVIEW, I've only been using it for a few weeks but your help as well as that from others on different issues has improved my learning curve. Thank you very much I appreciate your patience and persistance.
0 Kudos
Message 7 of 13
(4,338 Views)
I'm not sure if you are interested in pursuing further. If you are, post your original vi and size of array B and C. I plan to run a simulation with your vi putting random number in the Arrays.
0 Kudos
Message 8 of 13
(4,338 Views)
I'm attaching what I believe you need, please let me know what you come up with.
0 Kudos
Message 9 of 13
(4,338 Views)
Please can you save the vi's as ver 6? I forgot to mention that I have LabVIEW 6.0.
0 Kudos
Message 10 of 13
(4,338 Views)