Assign certain values to a variable

Assign certain values to a variable - Сообщения

#1 Опубликовано: 01.09.2021 10:44:15
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: 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 Опубликовано: 01.09.2021 11:28:36
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Attach your Smath work sheet !
#3 Опубликовано: 01.09.2021 11:41:06
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: User

Test.sm (5 КиБ) скачан 35 раз(а).

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 Опубликовано: 01.09.2021 11:56:16
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: 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 Опубликовано: 01.09.2021 13:04:53
Fridel Selitsky

Fridel Selitsky

520 сообщений из 451 понравились пользователям.

Группа: User

One of the options
1 пользователям понравился этот пост
Stefan Müller 01.09.2021 15:09:00
#6 Опубликовано: 01.09.2021 13:25:26
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: 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 Опубликовано: 01.09.2021 13:56:54
Fridel Selitsky

Fridel Selitsky

520 сообщений из 451 понравились пользователям.

Группа: User

Wrote a little differently
Test Mod.sm (6 КиБ) скачан 45 раз(а).
1 пользователям понравился этот пост
Stefan Müller 01.09.2021 15:09:00
#8 Опубликовано: 01.09.2021 14:02:57
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: User

ok thank you i think i got a solution for now

Worksheet1.sm (7 КиБ) скачан 46 раз(а).

thank you
#9 Опубликовано: 01.09.2021 14:21:59
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: User

Decision Variable.sm (7 КиБ) скачан 31 раз(а).

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 Опубликовано: 01.09.2021 16:18:07
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

not with if else


Try if/otherwise from f(x) menu cases

if_otherwise.PNG
1 пользователям понравился этот пост
Stefan Müller 07.09.2021 07:21:00
#11 Опубликовано: 01.09.2021 16:39:03
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: 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 КиБ) скачан 36 раз(а).

2021-09-01_22-38.png
1 пользователям понравился этот пост
Stefan Müller 07.09.2021 07:21:00
#12 Опубликовано: 02.09.2021 03:17:31
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: 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 Опубликовано: 02.09.2021 03:26:01
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Stefan Müller 07.09.2021 07:21:00
#14 Опубликовано: 02.09.2021 08:05:15
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Stefan Müller 07.09.2021 07:21:00
#15 Опубликовано: 02.09.2021 08:30:15
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Stefan Müller 07.09.2021 07:22:00
#16 Опубликовано: 02.09.2021 08:43:08
Stefan Müller

Stefan Müller

0 сообщений из 45 понравились пользователям.

Группа: User

Ok thank you i think i got it i can expand it with a "shift" + "," pushing then if cases will be added
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений