LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add all the previous values of an array till the index value

Solved!
Go to solution

Hi, 

I'm a little new to LABVIEW. I'm working on a program in which I will enter a number and the program will take the values corresponding to that from a .csv file. If I enter 7, I need to add a particular column value( let's say 5th column) till that 7th value. The way which I want to add is like I will be using them in a formula and after finding the answer, I need to add that value to the previous value. Please help me with this.

 

I tried using shift register but I'm not able to change the values inside the for loop on each iteration( for calculating the answer using the formula). The blue line shows the index value. I'm using LABVIEW 2011.

 

 

Download All
0 Kudos
Message 1 of 14
(3,746 Views)

Hi niks,

 

I want to add is like I will be using them in a formula and after finding the answer, I need to add that value to the previous value.

Then you should use that previous value in adding to your current "formula" result - instead of adding zero…

 

Btw. we cannot debug images using LabVIEW. Why don't you attach your VI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(3,722 Views)

Hi, 

 

I know I've to add that. But couldn't figure out how to add the previous value. That's why I added zero there. Have added the VI  along with this. 

0 Kudos
Message 3 of 14
(3,719 Views)

You tried a shift register, but all you did was put the value into an indicator.  And the code you showed makes me even more confused than your problem description.  Perhaps an example of input data and what you expect for an output would help.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 14
(3,715 Views)

@niks9792 wrote:

But couldn't figure out how to add the previous value. That's why I added zero there. Have added the VI  along with this. 


You couldn't figure out how to use a simple wire?



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 14
(3,711 Views)

Hi,

 

     Sorry for the confusing VI. Simply what I want is the total TCO for the number of months which I enter. If it is 48, I need it to calculate the TCO of that particular year using the equation and I need to calculate the TCO till that month(0-12,12-24,24-36) and I've to add that with the final answer. The first year the TCO is calculated normally and in the 2nd year(12-24 months), I need to calculate the TCO of that particular year and then add the previous value. Like that it should go on. I hope you got my question.

0 Kudos
Message 6 of 14
(3,710 Views)

Hi,

 

    This one I know. But the issue is how to connect the previous value which is found by the equation(finding that part is which is confusing).

0 Kudos
Message 7 of 14
(3,706 Views)

Hi niks,

 

how to connect the previous value which is found by the equation

As shown in crossrulz' snippet!

(That random()-function is just a replacement for your "equation"-ExpressVI…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 14
(3,693 Views)

Hi,

 

 

     How to find the answer by using that equation? That is if I enter the 5th index, how to calculate the total until that particular value? 

0 Kudos
Message 9 of 14
(3,688 Views)
Solution
Accepted by topic author niks9792

Array Subset      Sum Array.

Message 10 of 14
(3,682 Views)