Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline MathUser123  
#1 Posted : 31 December 2021 19:02:56(UTC)
MathUser123

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.

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline overlord  
#2 Posted : 31 December 2021 20:09:10(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,126
Turkey

Was thanked: 507 time(s) in 338 post(s)
If I understood correct, what you need is cases() function.
Offline fedeghi  
#3 Posted : 31 December 2021 21:22:15(UTC)
fedeghi


Rank: Advanced Member

Groups: Registered
Joined: 14/09/2013(UTC)
Posts: 90
Italy

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.
Offline Jean Giraud  
#4 Posted : 31 December 2021 22:49:17(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: MathUser123 Go to Quoted Post
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

Offline overlord  
#5 Posted : 01 January 2022 14:07:11(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,126
Turkey

Was thanked: 507 time(s) in 338 post(s)
You can make cases() as a function.
This will make mpa value easily calculated.

Regards

2022-01-01_14-06.png
Offline Jean Giraud  
#6 Posted : 01 January 2022 14:38:58(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Inspired from overlord.

Inspired.PNG
Offline overlord  
#7 Posted : 01 January 2022 17:54:28(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,126
Turkey

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

2022-01-01_17-51.png
Offline MathUser123  
#8 Posted : 01 January 2022 22:12:49(UTC)
MathUser123

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…
Offline CBG  
#9 Posted : 02 January 2022 01:43:51(UTC)
CBG


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

Define_a_Variable_Ajust_by_Last_Square.sm (59kb) downloaded 52 time(s).


Best Regards

Carlos
Offline Jean Giraud  
#10 Posted : 02 January 2022 05:11:01(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

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).
Offline CBG  
#11 Posted : 02 January 2022 05:33:44(UTC)
CBG


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
Users browsing this topic
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.