Assign certain values to a variable

Assign certain values to a variable - Messages

#1 Posted: 9/1/2021 10:44:15 AM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

Hallo guys i have a problem and i dont know how to write it in smath.

for example:

i have a variable and i want to assign certain values depending on other values.

for example:

Variables:

a=1
b=2
e=1 or 2 for example

and now:

c:= a if e=1
b if e=2


and then

OK if c=1
NOK if c=2

also i can remember the function sverweis in mathcad to assign certain values to a variable out of a matrix

i dont know how to write in smath
i know its easy example but its only for demonstration

I know how to write in mathcad but not in smath
thank you br Stefan
#2 Posted: 9/1/2021 11:28:36 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Attach your Smath work sheet !
#3 Posted: 9/1/2021 11:41:06 AM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

Test.sm (5 KiB) downloaded 35 time(s).

just trying. I think i got it but is there a better way to assign such values?

I just want to do it with if only

So that

e:= if a=1 then e=10
if a=2 then e=11
if a=3 then e=12
if a=4 then e=13
if a=5 then e=14
if a=6 then e=15

like this way



and so on not with if else if else is a little bit confusing


thank you best regards stefan
#4 Posted: 9/1/2021 11:56:16 AM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

i think i have a similar problem like this on here:


https://en.smath.com/forum/yaf_postst723_if-without-else.aspx


if without else

is there somehow a workaround?
#5 Posted: 9/1/2021 1:04:53 PM
Fridel Selitsky

Fridel Selitsky

520 likes in 451 posts.

Group: User

One of the options
1 users liked this post
Stefan Müller 9/1/2021 3:09:00 PM
#6 Posted: 9/1/2021 1:25:26 PM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

thank you but im having troubles writing this code.

How you write the if without else and how do you write the otherwise


i see no otherwise and i always have the if with else statement

or do i need a plugin for your function?

thank you
#7 Posted: 9/1/2021 1:56:54 PM
Fridel Selitsky

Fridel Selitsky

520 likes in 451 posts.

Group: User

Wrote a little differently
Test Mod.sm (6 KiB) downloaded 45 time(s).
1 users liked this post
Stefan Müller 9/1/2021 3:09:00 PM
#8 Posted: 9/1/2021 2:02:57 PM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

ok thank you i think i got a solution for now

Worksheet1.sm (7 KiB) downloaded 47 time(s).

thank you
#9 Posted: 9/1/2021 2:21:59 PM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

Decision Variable.sm (7 KiB) downloaded 32 time(s).

i now encounter another problem. If i have many decisions how can i align the variables vertically?

I have not enough place on the sheet so that every variable can stay there in one row

like in the sheet
#10 Posted: 9/1/2021 4:18:07 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

not with if else


Try if/otherwise from f(x) menu cases

if_otherwise.PNG
1 users liked this post
Stefan Müller 9/7/2021 7:21:00 AM
#11 Posted: 9/1/2021 4:39:03 PM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

Are you trying to achieve this?
It takes very little space on sheet.
You did mentioned vlookup function.
This gives a variable depending on a decision.
Or maybe I have lost in the context.

Regards

decision_r1.sm (4 KiB) downloaded 36 time(s).

2021-09-01_22-38.png
1 users liked this post
Stefan Müller 9/7/2021 7:21:00 AM
#12 Posted: 9/2/2021 3:17:31 AM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

@ Jean i dont find this f(x) menü cases. Do i need a plugin for this feature?

can you describe me how i do get to this if otherwise statement?


Thank you for the support so far. Im really beginner to smath
#13 Posted: 9/2/2021 3:26:01 AM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Wrote

@ Jean i dont find this f(x) menü cases. Do i need a plugin for this feature?

can you describe me how i do get to this if otherwise statement?


Thank you for the support so far. Im really beginner to smath



It is the function cases from custom functions plugin. To add more "if cases" you have to type twice your argument separator key.

If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Stefan Müller 9/7/2021 7:21:00 AM
#14 Posted: 9/2/2021 8:05:15 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

@ Jean i don't find this f(x) menü cases. Do I need a plugin for this feature?
Can you describe me how I do get to this if otherwise statement ?



Cases [if_otherwise].PNG

1 users liked this post
Stefan Müller 9/7/2021 7:21:00 AM
#15 Posted: 9/2/2021 8:30:15 AM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

Wrote

Do i need a plugin for this feature?
Can you describe me how i do get to this if otherwise statement?
Thank you for the support so far. I'm really beginner to smath


You need to install Custom Functions plugin.
After you have installed Custom Functions plugin;
You can either enter it from menu, Insert > Function > Cases().
Or you can press Ctrl+E key combination and insert Cases().
Or simply type cases(), press Tab or click on it and will be added.
Last one is how most people insert it I guess.

Please don't hesitate to ask anything.
You will find out this is one of the most friendly forums on internet.
Everyone is eager to help and shall try to reply your questions.

Regards
1 users liked this post
Stefan Müller 9/7/2021 7:22:00 AM
#16 Posted: 9/2/2021 8:43:08 AM
Stefan Müller

Stefan Müller

0 likes in 45 posts.

Group: User

Ok thank you i think i got it i can expand it with a "shift" + "," pushing then if cases will be added
  • New Posts New Posts
  • No New Posts No New Posts