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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Programming in Mathcad

EN_9902818
12-Amethyst

Programming in Mathcad

Hi,

 

I'm trying to build a program so that when I choose a variable to present a set of calculations but when I choose another variable to see in the mathcad spreadsheet another set of calculations. Do you know if this can be done?

I was thinking the a,b & c to be different mathcad sheets. Please see attached

 

thanks,

Eleni

8 REPLIES 8
StuartBruff
23-Emerald III
(To:EN_9902818)


@EN_9902818 wrote:

Hi,

 

I'm trying to build a program so that when I choose a variable to present a set of calculations but when I choose another variable to see in the mathcad spreadsheet another set of calculations. Do you know if this can be done?

I was thinking the a,b & c to be different mathcad sheets. Please see attached

 

thanks,

Eleni


Something like this, Eleni?

 

StuartBruff_0-1644587282611.png

 

The programmed version should work in Mathcad Prime 7, but I've only got Mathcad Express 7 so I can't check it.

The second version (using if functions) works in Express.

 

I've explicitly defined the values for a simply as an option, or you could define the values externally in variables, as I've done, or even in a matrix and select the appropriate column/row.

 

Stuart

Unfortunately, no

 

I didn't make it clear, sorry. What I intend to achieve is to give different input values as the direction changes.

Eg

If wind in x direction then I need to input the moment in y direction eg Mwy but if wind in y direction then I need to input the moment in x direction eg Mxy. And then based on these inputs present only the calculations that correspond to the specific wind case. Like a mini program.

Is it any chance can this be done with mathcad?

If not, is it any chance of changing the subscript between x and y to the moment following choosing y or x wind accordingly?

 

cheers,

Eleni

LucMeekes
23-Emerald III
(To:EN_9902818)

Do I understand you correctly that when the wind is in x direction you need to calculate completely different things than when the wind is in y direction? Are there only two wind directions? What if the wind is in between x and y direction?

And what about 'x' and 'y'? (I see you had an x in one of your formulae).

 

Success!
Luc

LucMeekes
23-Emerald III
(To:EN_9902818)

I don't think you can programmatically choose a sheet (whether or not dependent on the value of a variable) to work with.

If your calculations are independent on the wind direction then whatever Stuart suggested should work for you.

If not, try to approach it as follows:

You have four parameters Fgz, Fwx, Mgy and Mwy and the wind direction Dir. Now define functions for any calculations that depend on those parameters.

E.g.

Fdx(Fwx,Dir) := If (Dir="west", Vq*Fwx, <Whatever if it's not west>)

Mdx(Fgz,Fwx,Mgy,Mwy,Dir) := If(Dir="west", Vg*(Fsw*L/2 +Fgz*x)+Vq*(Mgy+MWy+Fwx*h), <Whatever if it's not west>)

etc.

 

Success!
Luc

 

When I build a calculation sheet from a national standard, it often contains a lot of choices, like "if the roof is sloped, use this formula; otherwise, use this other formula" or "this factor only applies if the material is glass". 

 

When I come across things like this, I write a question on the inputs page "Is the material glass?" and then the user types "yes" or "no" as a string in a variable next to the question. Later on in the sheet, when that question becomes relevant, I have an if statement with 'if "yes"', 'else if "no"', and 'else', where the else is just an error check to make sure that the string was yes or no. Inside the "if yes" or "if no" sections, the different formulas are applied. 

 

This way, you can include a lot of different formulas or methodologies in your calculation without having to make separate sheets for separate situations. 

 

I hope this helps!

 

DJF
16-Pearl
16-Pearl
(To:EN_9902818)

Not sure I understand exactly what you're after but this was my take.

 

Write 3 functions (programs) - one for each way the wind blows.

Have a program similar to yours with IF statements and only call the function needed based on the input.

 

It might not be the most condensed way, but should work.

Your wind direction could be an angle, and then your wind load on your structure would just be sin(a)*Fy + cos(a)*Fx. I think this is all you really need in your sheet. Does this help?

ttokoro
20-Turquoise
(To:EN_9902818)

Prime 7

Definition of function

Do the function.

 

Announcements

Top Tags