Pick a number from a list if condition is meet

Pick a number from a list if condition is meet - Сообщения

#1 Опубликовано: 12.03.2024 15:31:22
Alex Costila

Alex Costila

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

Группа: User

How can i pick a speed based on a "n" value.


Let's say my n= 13 i want to get the value 30km/h for V, but if its 8 i want 60km/h.
I have tried with for/while/if. But im guessing im doing something wrong or i don't know what to write exactly.


Any help is much apprecite it!
#2 Опубликовано: 12.03.2024 17:18:17
Martin Kraska

Martin Kraska

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

Группа: Moderator

Worksheet6.png
Worksheet6.sm (4 КиБ) скачан 25 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#3 Опубликовано: 12.03.2024 17:41:24
Alex Costila

Alex Costila

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

Группа: User

Wrote

Worksheet6.png
Worksheet6.sm (4 КиБ) скачан 25 раз(а).



Thank you for the answer, but this doesn't help me. Or i don't understand it .

Example, i have N=10, based on N i want to get V. V for N=10 it's from here:
, but if i change N to 9 i want to obtain V=30km/hr.
Thing is i have 8 variable based on N, and i want to obtain the values only by changing N.


Sorry if i don't explain very well.
#4 Опубликовано: 12.03.2024 18:28:42
Martin Kraska

Martin Kraska

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

Группа: Moderator

The procedure is to get a vector of the potential values which can then be accessed by index.
You also could implement it as a function v(n) = 30 + mod(n-1, 4)*10

Worksheet6a.png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#5 Опубликовано: 12.03.2024 18:51:40
Alex Costila

Alex Costila

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

Группа: User

Wrote

The procedure is to get a vector of the potential values which can then be accessed by index.
You also could implement it as a function v(n) = 30 + mod(n-1, 4)*10

Worksheet6a.png



Great it works now. I just have to figure it out how to implement it for the rest of the file .
Thank you very much!

How would you tackle this one?
#6 Опубликовано: 12.03.2024 20:52:27
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote



Great it works now. I just have to figure it out how to implement it for the rest of the file .
Thank you very much!

How would you tackle this one?



Divide n by 2, a bit of rounding and offset adjustment should do the job.

Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#7 Опубликовано: 18.03.2024 20:26:30
Alex Costila

Alex Costila

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

Группа: User

Wrote

Wrote



Great it works now. I just have to figure it out how to implement it for the rest of the file .
Thank you very much!

How would you tackle this one?



Divide n by 2, a bit of rounding and offset adjustment should do the job.



I can't seem to get it to work, and for next examples i need to match it with a list that has some randomnes in number list. Isn't there a way i can create a list of number and if my "n" matches that list then i can get the correct value? I tried with for, if and so on. but im still a newbie in Smath.

Thank you once again!
#8 Опубликовано: 18.03.2024 21:19:04
Davide Carpi

Davide Carpi

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

Группа: Moderator

If you have a limited set of choiches, this might be a solution.

Screenshot 2024-03-18 141755.png

Also, I think Martin has a point, since these "n" values should come from some formula.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#9 Опубликовано: 19.03.2024 02:10:00
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote

Wrote

Wrote



Great it works now. I just have to figure it out how to implement it for the rest of the file .
Thank you very much!

How would you tackle this one?



Divide n by 2, a bit of rounding and offset adjustment should do the job.



I can't seem to get it to work, and for next examples i need to match it with a list that has some randomnes in number list. Isn't there a way i can create a list of number and if my "n" matches that list then i can get the correct value? I tried with for, if and so on. but im still a newbie in Smath.

Thank you once again!



If there is no rule, then you have to provide a vector with values and adress it with index n. A simple lookup table by index. Fill the vector by hand, by reading a file or asking a chatbot.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#10 Опубликовано: 19.03.2024 14:49:03
Alex Costila

Alex Costila

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

Группа: User

Wrote

If you have a limited set of choiches, this might be a solution.

Screenshot 2024-03-18 141755.png

Also, I think Martin has a point, since these "n" values should come from some formula.



This works but i have other areas with diferent increment and i can't control them with interval. I will list a few of them:

here is 1,2,3 then goes to 16,17,18 then 26,27,28.

So i have this interval from the picture above and the one before with "Latimea benzii".
#11 Опубликовано: 19.03.2024 15:57:49
Alex Costila

Alex Costila

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

Группа: User

Wrote

Wrote

If you have a limited set of choiches, this might be a solution.

Screenshot 2024-03-18 141755.png

Also, I think Martin has a point, since these "n" values should come from some formula.



This works but i have other areas with diferent increment and i can't control them with interval. I will list a few of them:

here is 1,2,3 then goes to 16,17,18 then 26,27,28.

So i have this interval from the picture above and the one before with "Latimea benzii".



Found a not very fancy solution, but it works .
pick a number from a list.sm (6 КиБ) скачан 23 раз(а).
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений