Assign certain values to a variable

Assign certain values to a variable - Mensajes

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

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: 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 Publicado: 1/9/2021 11:28:36
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

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

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: User

Test.sm (5,83 KiB) descargado 1202 vez(es).

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 Publicado: 1/9/2021 11:56:16
Stefan Müller

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: 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 Publicado: 1/9/2021 13:04:53
Fridel Selitsky

Fridel Selitsky

520 me gusta en 451 mensajes.

Grupo: User

One of the options
A 1 usuarios les gustó este mensaje
Stefan Müller 1/9/2021 15:09:00
#6 Publicado: 1/9/2021 13:25:26
Stefan Müller

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: 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 Publicado: 1/9/2021 13:56:54
Fridel Selitsky

Fridel Selitsky

520 me gusta en 451 mensajes.

Grupo: User

Wrote a little differently
Test Mod.sm (6,62 KiB) descargado 1236 vez(es).
A 1 usuarios les gustó este mensaje
Stefan Müller 1/9/2021 15:09:00
#8 Publicado: 1/9/2021 14:02:57
Stefan Müller

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: User

ok thank you i think i got a solution for now

Worksheet1.sm (7,91 KiB) descargado 1236 vez(es).

thank you
#9 Publicado: 1/9/2021 14:21:59
Stefan Müller

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: User

Decision Variable.sm (7,85 KiB) descargado 1254 vez(es).

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 Publicado: 1/9/2021 16:18:07
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

not with if else


Try if/otherwise from f(x) menu cases

if_otherwise.PNG
A 1 usuarios les gustó este mensaje
Stefan Müller 7/9/2021 7:21:00
#11 Publicado: 1/9/2021 16:39:03
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: 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,12 KiB) descargado 1180 vez(es).

2021-09-01_22-38.png
A 1 usuarios les gustó este mensaje
Stefan Müller 7/9/2021 7:21:00
#12 Publicado: 2/9/2021 3:17:31
Stefan Müller

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: 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 Publicado: 2/9/2021 3:26:01
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: 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
A 1 usuarios les gustó este mensaje
Stefan Müller 7/9/2021 7:21:00
#14 Publicado: 2/9/2021 8:05:15
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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

A 1 usuarios les gustó este mensaje
Stefan Müller 7/9/2021 7:21:00
#15 Publicado: 2/9/2021 8:30:15
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: 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
A 1 usuarios les gustó este mensaje
Stefan Müller 7/9/2021 7:22:00
#16 Publicado: 2/9/2021 8:43:08
Stefan Müller

Stefan Müller

0 me gusta en 45 mensajes.

Grupo: User

Ok thank you i think i got it i can expand it with a "shift" + "," pushing then if cases will be added
  • Nuevos mensajes
  • Sin mensajes nuevos