10-26-2011 06:55 AM
Hello! pls, can any one assist, i have six variables and want to take the sum of each variable separately from middle iteration to last iteration( that is from iteration 6 to iteration 12). Attached are the vi and input data file.
Solved! Go to Solution.
10-27-2011 05:13 PM
Hello Abul,
Is there any reason you are using Control Design and Simulation? It seems like you could do the iteration and sum from our Mathematics palette. Also, I believe you will want to use While loop for your iteration count. Using these tools will be easier than trying to get this done with your current VI.
Mychal F
10-27-2011 07:09 PM
I'm not going to mess with your control design thingy... but here is the simple and direct way to take the sum of the middle to last interation. I'm using random numbers here, but you can fill in your own values once you get your formula straigthend out.
Basically, it works like this: feed the values into an indexing tunnel. That will make each set of values into an array with length N where N is number of iterations.
Find the size of the array and divide by 2. Remember that arrays start at index zero, so 12 iterations will give you 0,1,2,3,4,5,6,7,8,9,10,11.
You want the second half, so that's 6,7,8,9,10 and 11. Use array subset to pick out 6 elements starting at element 6.... then take the array sum.
10-28-2011 01:44 AM
Is because of the use of integrator.
10-28-2011 06:46 AM
Kudos
10-29-2011 01:39 AM
I did as u directed but still when i run nothing comes out as the sum of each variable from middle iteration to the last, or is it because i see the simulation loop runs faster than the while loop. How do i synchronize the two? i.e the simulation loop and while loop to run at the same rate. Attached are the vi and input data file complete. Thanks
10-31-2011 10:35 AM
Because the simulation loop is inside the While loop, they cannot be synchronized.
What happens is this:
Each time this happens, one value is placed in the output of the while loop.
The first thing you need to do is delete the random number generators that I put in. These were just there for demonstration purposes. You should wire the output of your X1, X2, X3, etc to the outputs of the while loop (the tunnels at the right edge.) If not, there's no way for your data to get out of the loop.
Also, I'm really worried about the simulation loop. In fifteen years, I have never needed or used this feature. I've done quite a lot of complex math and I've always built my functions from the basic LabView toolset. So I can't help you with that part, but I really think you'd be better off if you got rid of it.
10-31-2011 10:54 PM
Initially i did it that way it does not work. I can get rid of simulation loop but is not possible for me to use integrator in while loop, i tried it does not work , i want to use integrators to have solution variable equations not as deratives or is there any way to have solution of equations using while loop without use of integrators. Thanks
11-01-2011 03:56 AM
Initially i have done it that way it does not work as attached. What i am interested is to use integrators from control and simulation because of the initial condition of the variables to solve the differential using formula node inside while loop so that i take the sum from middle iteration to the last but the integrator can not be inserted in while loop that is why i used simulation loop, i want to get rid of it because of this synchronization problem. I want solve the differential equations if not using integrators how do i go about it. Thanks
11-01-2011 11:35 AM
Hi Abul,
You will still be able to solve differential equations by using VIs built in on the Mathematics portion of your Functions palette. I have linked you to a website here that discusses the different VIs on this palette. Using these will help you solve the differential equations and allow you to move away from the Simulation Loop. Hope this helps!
Mychal F