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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Multiple input with units

qm
6-Contributor
6-Contributor

Multiple input with units

Hello,

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

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(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
12-Amethyst
(To:qm)

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

Werner_E
24-Ruby V
(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

 

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
6-Contributor
6-Contributor
(To:Werner_E)

Thank you very much FredLusk and Werner_E !

You both save may day.

Best regards,

Quinn

FredLusk
12-Amethyst
(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.

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

 

 

Top Tags