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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

How to Create A Loop to Calculate a Cummulative Variable

ptc-5031264
1-Visitor

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

Werner_E
25-Diamond I
(To:ptc-5031264)

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.

Werner_E
25-Diamond I
(To:ptc-5031264)

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)?

Werner_E
25-Diamond I
(To:ptc-5031264)

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

Announcements

Top Tags