04-29-2013 02:16 AM
Hi,
I am trying to insert for loop loop itration values into two arrays and trying to plot using XY graph. I need values shouls be inserted one by one in each iteration. But at the end of iteration in array I am getting only last value.. can anyone help me?
Solved! Go to Solution.
04-29-2013 02:46 AM
Hi ef,
did you try to debug that VI with highlighting and probes? You really should have to...
What do you expect when you create a new array on each iteration (by InitArray)?
What do you expect by inserting one element into that array?
What do you expect when you set the ExpressVI "Build XY graph" to "Delete data on each call"?
04-29-2013 03:34 AM
Hi GerdW,
I tried your solution but no graph came. I asked this as part of my project. My real intention is to add values into array and plot it in real time. But by using your solution i will get array only after complete iteration of for loop. For each iteration insert some values into array without deleting the old value.. just add new element into next location. can you provide any idea??
Thanking you,
Manu
04-29-2013 03:39 AM - edited 04-29-2013 03:42 AM
Hi Manu,
use a shift register to store each array. Use BuildArray to prepend/append (not insert!) new values to the array!
Then you don't need to use an ExpressVI to create the graph, a simple bundle node (as shown in the context help) is sufficient to create a plot for an XY graph...
Example with just one array:
Keep in mind:
This is not (memory/CPU time) efficient to be used for long time data aquisition (resulting in big arrays). Use different approaches then...
04-29-2013 04:01 AM
Hi Gerd,
I am very thankful to you for giving great solution, saving my time and spending your time for me. I was struck in this problem for few hours.
Thanking you,
Manu
04-29-2013 09:23 AM
Hi ef,
you really should not create double post for the same question/topic!
All you do is keep people busy to provide the same answer in several places!
03-17-2014 01:29 PM
Hi everyone,
I am trying to write datas generated by For Loop into an initialized array (8*8). There are 3 For Loops. I want the datas of each iteration to be inputted in the initialized array one by one, but actually at the end of iterations I only got the last values of iteration (the latter values covered the former ones), so I got the array of 2*8. Please see the attached VI.
I am using Labview 2012.
Thanks so much!
Yimi
03-17-2014 01:55 PM - edited 03-17-2014 02:22 PM
Yimi168 wrote:I am trying to write datas generated by For Loop into an initialized array (8*8). There are 3 For Loops. I want the datas of each iteration to be inputted in the initialized array one by one, but actually at the end of iterations I only got the last values of iteration (the latter values covered the former ones), so I got the array of 2*8. Please see the attached VI.
Why not use two 8x FOR loops instead. See attached.
Modify as needed. If you also want to see the intensity graph update in real time, it's terminal would belong inside the inner FOR loop, of course.
(You have a serious overuse of sequence structures and local variables. None are needed. You are also not properly incrementing the indices of the insert point. And please don't maximise the front panel to the screen, that is just annoying).
03-17-2014 02:20 PM
Thank you very much, Altenbach.
Just as you said, I overused the sequence structures and local variables. Thanks a lot to learn from you.
But this vi is a simplified vi of my problem. In the second loop of my original Labview program, there is another sequence structure where my third loop is. Actually, the datas generated are more complicated than the random generator. I just want to know if it is possible to solve my problem in my case, I want the datas of each iteration to be inputted in the initialized array one by one, not covered by datas of the next iteration.
Thanks a lot!
03-17-2014 02:26 PM - edited 03-17-2014 02:26 PM
Yimi168 wrote:But this vi is a simplified vi of my problem. In the second loop of my original Labview program, there is another sequence structure where my third loop is. Actually, the datas generated are more complicated than the random generator. I just want to know if it is possible to solve my problem in my case, I want the datas of each iteration to be inputted in the initialized array one by one, not covered by datas of the next iteration.
I don't like text descriptions, because they are too ambiguous. Please attach the actual code instead.
If you look at your math to calculate the insert point, you see that you never increment the row index. You need to change the math based on the value of all iteration terminals. That's it!
Also note that your code does NOT replace elements one-by-one as you say, but two at a time (place a small wait to see what's happening!)