cancel
Showing results for
Did you mean:
cancel
Showing results 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

4-Participant

## IF programming question

Hi all,

For the attached sheet, I am trying to calculate the mid-point of each layer using an if statement. The values are entered using an Excel table. For the first layer, the mid-point is simply H0/2 (so 0.9 m). For the second layer, the mid-point is the previous mid-point, plus the average of the previous and current points (so, 0.9 m + (1.8+1.6)/2 =  2.6 m). For some reason however, the simple IF code I am trying to use doesn't seem to work. I am not very familiar with programming in Mathcad, so any help would be appreciated.

Thanks!

-Fikret

1 ACCEPTED SOLUTION

Accepted Solutions
23-Emerald III
(To:ftatl63)

I guess this is what you're after.

Recreate the little program in your Prime, and it should work.

Success!
Luc

9 REPLIES 9
23-Emerald I
(To:ftatl63)

@ftatl63 wrote:

Hi all,

For the attached sheet, I am trying to calculate the mid-point of each layer using an if statement. The values are entered using an Excel table. For the first layer, the mid-point is simply H0/2 (so 0.9 m). For the second layer, the mid-point is the previous mid-point, plus the average of the previous and current points (so, 0.9 m + (1.8+1.6)/2 =  2.6 m). For some reason however, the simple IF code I am trying to use doesn't seem to work. I am not very familiar with programming in Mathcad, so any help would be appreciated.

Thanks!

-Fikret

Why isn't the midpoint of the second layer half the thickness of the second layer plus the whole first layer?

(1.8 + 1.6/2)

4-Participant
(To:Fred_Kohlhepp)

Both would return the same result, but the if statement still doesn't work because it appears the statement does not store the value for z0. Thanks.

23-Emerald I
(To:ftatl63)

I can't see Prime 5 files.  Can you attach a pdf file?

23-Emerald I
(To:Fred_Kohlhepp)

Who needs programming?

See attached version 4 file (readable in 5)

4-Participant
(To:Fred_Kohlhepp)

23-Emerald III
(To:ftatl63)

I guess this is what you're after.

Recreate the little program in your Prime, and it should work.

Success!
Luc

4-Participant
(To:LucMeekes)

After I posted, I realized I am missing a for loop to step through the iterations 🙂 What you posted should work; thank you very much!

23-Emerald I
(To:ftatl63)

A range variable works like a for loop

23-Emerald I
(To:ftatl63)

A range variable works like a for loop.

Announcements