SMath Studio Forum
»
SMath Studio
»
Questions
»
Pick a number from a list if condition is meet
Rank: Member Groups: Registered
Joined: 12/03/2024(UTC) Posts: 10 Was thanked: 1 time(s) in 1 post(s)
|
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!
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,987 Was thanked: 1124 time(s) in 721 post(s)
|
|
|
|
|
|
Rank: Member Groups: Registered
Joined: 12/03/2024(UTC) Posts: 10 Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: mkraska 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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,987 Was thanked: 1124 time(s) in 721 post(s)
|
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 |
|
|
|
|
Rank: Member Groups: Registered
Joined: 12/03/2024(UTC) Posts: 10 Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: mkraska 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 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? Edited by user 13 March 2024 01:42:46(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,987 Was thanked: 1124 time(s) in 721 post(s)
|
Originally Posted by: Obliterate 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. |
|
|
|
|
Rank: Member Groups: Registered
Joined: 12/03/2024(UTC) Posts: 10 Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: mkraska Originally Posted by: Obliterate 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!
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
If you have a limited set of choiches, this might be a solution. Also, I think Martin has a point, since these "n" values should come from some formula. Edited by user 19 March 2024 04:39:52(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,987 Was thanked: 1124 time(s) in 721 post(s)
|
Originally Posted by: Obliterate Originally Posted by: mkraska Originally Posted by: Obliterate 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. |
|
|
|
|
Rank: Member Groups: Registered
Joined: 12/03/2024(UTC) Posts: 10 Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: Davide Carpi If you have a limited set of choiches, this might be a solution. 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".
|
|
|
|
Rank: Member Groups: Registered
Joined: 12/03/2024(UTC) Posts: 10 Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: Obliterate Originally Posted by: Davide Carpi If you have a limited set of choiches, this might be a solution. 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 (7kb) downloaded 3 time(s).
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
Pick a number from a list if condition is meet
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.