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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

IF programming question

ftatl63
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
LucMeekes
23-Emerald III
(To:ftatl63)

I guess this is what you're after.

LM_20190225_IfStatement.png

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

 

Success!
Luc

View solution in original post

9 REPLIES 9


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

ftatl63
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.

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

Who needs programming?

 

See attached version 4 file (readable in 5)

ftatl63
4-Participant
(To:Fred_Kohlhepp)

 
LucMeekes
23-Emerald III
(To:ftatl63)

I guess this is what you're after.

LM_20190225_IfStatement.png

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

 

Success!
Luc

ftatl63
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!

A range variable works like a for loop

A range variable works like a for loop.

Top Tags