SMath Studio Forum
»
SMath Studio
»
Questions
»
Definition of Variables with several "if".
Rank: Newbie
Groups: Registered
Joined: 31/12/2021(UTC) Posts: 2
|
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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,126 Was thanked: 507 time(s) in 338 post(s)
|
If I understood correct, what you need is cases() function.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 14/09/2013(UTC) Posts: 90 Was thanked: 24 time(s) in 16 post(s)
|
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.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: MathUser123 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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,126 Was thanked: 507 time(s) in 338 post(s)
|
You can make cases() as a function. This will make mpa value easily calculated. Regards
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Inspired from overlord.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,126 Was thanked: 507 time(s) in 338 post(s)
|
Just a reminder, you should watch for order in cases. Once one if condition is provided, below won't be regarded. Regards
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 31/12/2021(UTC) Posts: 2
|
Hey, thank you all. You are awesome. It worked. Thanks for your detailed inputs. Regards…
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 14/10/2015(UTC) Posts: 308
Was thanked: 77 time(s) in 58 post(s)
|
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_Ajust_by_Last_Square.sm (59kb) downloaded 52 time(s).Best Regards Carlos
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Hola Carlos, best 2022. Pretty clean Quadratic fit ! Take care ... Jean Quadratic fit.sm (15kb) downloaded 17 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 14/10/2015(UTC) Posts: 308
Was thanked: 77 time(s) in 58 post(s)
|
Hola Jean
Feliz y Prospero 2022
Nice quadratic fit, thanks
Cuidate mucho
Carlos
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
Definition of Variables with several "if".
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.