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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Programming function Mathcad 15

smilani
5-Regular Member

Programming function Mathcad 15

Dear all,

How can I set this programming function in mathcad 15?

Programming.png

Regards

Stefano

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:smilani)

Stuart uses the symbol in the 'if' statement

which is the mathematical notation for a logic AND operator, simply because multiple conditions need to be satisfied simultaneously.

(just like there is the OR: that you can use when one of a number of conditions needs to be true)

They are found on the pallette with boolean symbols.

Now to your:

There are two types of subscripts used in Mathcad. Real and literal. Real subscripts are used to point to elements of a vector or matrix, as Stuart explained following his explanation on programming. The other type of subscripts is a literal subscript, which just puts part of the variable name in the subscript position. You type it by using a dot: '.'. So if you type a variable name in with: A.b, you get .

You cannot nest literal subscripts. Typing A.b.c gives you . Notice that the second dot gets visible as a dot.

When you type A.b,c you get . This means you're addressing the c'th element of the vector A.b. Essentially there are two variables here, separated by the comma: the vector A.b and the (index) variable c.

You can, if you really want to, embed a comma in a subscript, without it meaning the separation of two variables. By pressing [CTL-SHFT-k] you enter symbolic entry mode where you can enter symbols that show. To exit symbol entry mode press [CTL-SHFT-k] again. So to enter the DeltaSess,k variable as a single variable you should type:

D[CTL-g]S.ess[CTL-SHFT-k],[CTL-SHFT-k]k.

{The [CTL-g] is to convert from d to delta.}

Success!
Luc

View solution in original post

6 REPLIES 6
StuartBruff
23-Emerald II
(To:smilani)

Stefano Milani wrote:

Dear all,

How can I set this programming function in mathcad 15?

Programming.png

Regards

Stefano

The general structure of a conditional program in Mathcad is something along the lines of ...

Here I've simply used the catchall "otherwise" (equivalent to "else" in many other programming languages) rather than type in the whole of that expression.   A word of caution here ... you have to be careful to make sure that your conditional catches all of the possible outcomes - in this case, you'd probably want to use another "if" statement for the second case and an "otherwise" to trap anything that didn't meet these two conditions.

The specifics of how you implement this equation depend upon the exact nature of your expression. Is f a function of the two arguments M and k? Or is f a matrix (tensor?)?.  If your Delta-sigma with the parameters e, m & k is meant to be a tensor, then your first problem will be deciding how to represent the data in Mathcad, as there is no inherent Mathcad support for tensors - a nested array may be the way forward.

More details on what the expressions mean would be helpful.

Stuart

smilani
5-Regular Member
(To:StuartBruff)

The output value must be only a number (not matrix/tensor etc..) M and k subscript are only for  definition value (is a coefficient used in mechanical fatigue analysis and k indicate a stress state).

In this case the previous expression is correct? In your expression how can I obtain the following symbol?

symbol.png

and how can I insert "," in the subscript?

This  symbol (symbol.png) what does it indicate? and?

Thanks

Best regards

Stefano

StuartBruff
23-Emerald II
(To:smilani)

OK.  However, without some background on the notation, I can't offer much more guidance - notation, particularly domain-specific notation, can be difficult to interpret (eg, I'd have put good money (maybe as much as 0.01 euros) on this

being a tensor ("e" being italic makes it seem like it's a variable rather than the mathematical value 2.718281828459...

Do you have a reference to a website or pdf document that explains what you want to calculate?

Here's a brief summary of some of the kind of notation you might find useful in Mathcad 15 (Mathcad Prime has some subtle differences).

Stuart

smilani
5-Regular Member
(To:StuartBruff)

Dear Stuart,

this is an extract of ASME VIII div.2 Fatigue procedure (I can't reported the complete procedure, but I think that this extract permit to understand).

1.PNG

2.PNG

the k notation is refering to the k-th cycle.

In a simple case of cycling beetween max and zero value k is 1 because there are not another cycle condition.

Best regards

Stefano

LucMeekes
23-Emerald III
(To:smilani)

Stuart uses the symbol in the 'if' statement

which is the mathematical notation for a logic AND operator, simply because multiple conditions need to be satisfied simultaneously.

(just like there is the OR: that you can use when one of a number of conditions needs to be true)

They are found on the pallette with boolean symbols.

Now to your:

There are two types of subscripts used in Mathcad. Real and literal. Real subscripts are used to point to elements of a vector or matrix, as Stuart explained following his explanation on programming. The other type of subscripts is a literal subscript, which just puts part of the variable name in the subscript position. You type it by using a dot: '.'. So if you type a variable name in with: A.b, you get .

You cannot nest literal subscripts. Typing A.b.c gives you . Notice that the second dot gets visible as a dot.

When you type A.b,c you get . This means you're addressing the c'th element of the vector A.b. Essentially there are two variables here, separated by the comma: the vector A.b and the (index) variable c.

You can, if you really want to, embed a comma in a subscript, without it meaning the separation of two variables. By pressing [CTL-SHFT-k] you enter symbolic entry mode where you can enter symbols that show. To exit symbol entry mode press [CTL-SHFT-k] again. So to enter the DeltaSess,k variable as a single variable you should type:

D[CTL-g]S.ess[CTL-SHFT-k],[CTL-SHFT-k]k.

{The [CTL-g] is to convert from d to delta.}

Success!
Luc

LucMeekes
23-Emerald III
(To:LucMeekes)

There's an error in my statement:

"When you type A.b,c you get . This means you're addressing the c'th element of the vector A.b. Essentially there are two variables here, separated by the comma: the vector A.b and the (index) variable c."

The variable c is not adressing an element in the vector A.b, its just another variable separated from A.b. If I wanted it to address an element of A.b i''d have to press: A.b[c which gives:

Likewise the 1st element of the c'th column of matrix A.b is addressed by typing A.b[0,c, and shown as: .

Luc

Top Tags