cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to Create A Loop to Calculate a Cummulative Variable

ptc-5031264
1-Newbie

How to Create A Loop to Calculate a Cummulative Variable

I am new to Mathcad and I am having a problem with programming a simple loop. In the attached mathcad sheet I want to calculate the value of (q) and then I want it to add to (s) and then re-calculate (q) for the new (s) value. However, I am unable to do this using the programming function as shown in the Mathcad sheet. It seems to give the same answer through the loop. Please help. Thank you.

5 REPLIES 5

just need to move the summing line inside the for loop.

Capture.PNG

Regards

Andy

The attached examples of two different ways should help

Many thanks for the answer. It was very helpful. I got another question on how I could return the values of both s and q in the mathcad sheet. Thank you.

Ranjan Nadarajah wrote:

Many thanks for the answer. It was very helpful. I got another question on how I could return the values of both s and q in the mathcad sheet. Thank you.

Are you interested only in the last value of the iterations of both of them or do you need the whole "history"?

Said another way - do you want vectors for s and q or rather a single value (from the last iteration)?

I think one of the two attached methods should do the job

Top Tags