cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Multiple input with units

qm
7-Bedrock
7-Bedrock

Multiple input with units

Hello,

How can I fix this file in order that the multiple input to work with units?

Thank you

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:qm)

The problem is not because of the units, but rather because a comparison operator won't accept a vector as operand.

One way out would be to turn the calculation into a function (for scalar arguments) and then call this function with the vector as argument and use vectorization:

Werner_E_0-1582683232810.png

 

View solution in original post

6 REPLIES 6
FredLusk
14-Alexandrite
(To:qm)

This is probably not the most elegant, but it works.

Werner_E
25-Diamond I
(To:qm)

The problem is not because of the units, but rather because a comparison operator won't accept a vector as operand.

One way out would be to turn the calculation into a function (for scalar arguments) and then call this function with the vector as argument and use vectorization:

Werner_E_0-1582683232810.png

 

Werner_E
25-Diamond I
(To:Werner_E)

BTW, if you prefer the approach with the range variable of FredLusk, I would change it to something like the following to allow for input vectors with different sizes (personally I prefer the functional approach):

Werner_E_0-1582683465232.png

 

qm
7-Bedrock
7-Bedrock
(To:Werner_E)

Thank you very much FredLusk and Werner_E !

You both save may day.

Best regards,

Quinn

FredLusk
14-Alexandrite
(To:qm)

Werner is correct that the function approach is better.  I had a brain freeze that led me to the range variable, even though it works, too.

Werner_E
25-Diamond I
(To:FredLusk)

Many roads lead to Rome and which one ist "the best" may also be a matter of personal taste and depends on the circumstances you intend to use the approach. It is always good to have multiple options.

Here are some other, tricky and short ways to achieve the same goal:

Werner_E_0-1582761989501.png

 

 

Announcements

Top Tags