Definition of Variables with several "if".

Definition of Variables with several "if". - How to define a variable depending on other variables - 消息

#1 已发布: 2021/12/31 13:02:56
MathUser123

MathUser123

0个赞,共2个帖子。

组: User

Is it possible to define a variable, that depends on an other variable.

I want to define a variable like: "Mpa".

The "Mpa" is 400N/mm^2, if the variable "Diameter" is 12mm.
If the variable "Diameter" is 14mm, "MPA" should be 300N/mm^2.
If the variable "Diameter" is 16mm, "MPA" should be 250/mm^2.
...

At the end, the list is about 15 different possibilities.

I came from Mathcad. Mathcad has the option "add Line". With this, you can add as much "if"-Lines as you wand.
Is there a possibility to do this in Smath Studio also?

Thank you.
#2 已发布: 2021/12/31 14:09:10
overlord

overlord

600个赞,共1,381个帖子。

组: Moderator

If I understood correct, what you need is cases() function.
#3 已发布: 2021/12/31 15:22:15
fedeghi

fedeghi

25个赞,共112个帖子。

组: User

Please note that cases() function is not directly included in SMath "core" functions; you will find it after installing a plug-in called Custom Functions.
You can find it in SMath extension manager.
#4 已发布: 2021/12/31 16:49:17
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

I came from Mathcad. Mathcad has the option "add Line". With this, you can add as much "if"-Lines as you wand.
Is there a possibility to do this in Smath Studio also?


Lot more pro in Smath ... coma twice on any place holder.

Cases [if_otherwise] coma twice.PNG

#5 已发布: 2022/1/1 08:07:11
overlord

overlord

600个赞,共1,381个帖子。

组: Moderator

You can make cases() as a function.
This will make mpa value easily calculated.

Regards

2022-01-01_14-06.png
#6 已发布: 2022/1/1 08:38:58
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Inspired from overlord.

Inspired.PNG
#7 已发布: 2022/1/1 11:54:28
overlord

overlord

600个赞,共1,381个帖子。

组: Moderator

Just a reminder, you should watch for order in cases.
Once one if condition is provided, below won't be regarded.

Regards

2022-01-01_17-51.png
#8 已发布: 2022/1/1 16:12:49
MathUser123

MathUser123

0个赞,共2个帖子。

组: User

Hey, thank you all. You are awesome. It worked. Thanks for your detailed inputs.
Regards…
#9 已发布: 2022/1/1 19:43:51
CBG

CBG

78个赞,共312个帖子。

组: User

Hello

For this type of project, I try to fit the data to a curve and find its equation, and thus calculate any value in the specified range.

Although in this case, the values given are very few, as an example I annex the corresponding calculation.

Define_a_Variable.png

Define_a_Variable_Ajust_by_Last_Square.sm (58.17 KiB)已下载 1472 次。


Best Regards

Carlos
#10 已发布: 2022/1/1 23:11:01
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Hola Carlos, best 2022.
Pretty clean Quadratic fit !
Take care ... Jean

Quadratic fit.sm (14.45 KiB)已下载 1250 次。
#11 已发布: 2022/1/1 23:33:44
CBG

CBG

78个赞,共312个帖子。

组: User

Hola Jean

Feliz y Prospero 2022

Nice quadratic fit, thanks

Cuidate mucho

Carlos
  • 有新帖
  • 无新帖