Skip to main content
7-Bedrock
February 25, 2020
Solved

Multiple input with units

  • February 25, 2020
  • 2 replies
  • 2793 views

Hello,

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

Thank you

Best answer by Werner_E

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

 

2 replies

14-Alexandrite
February 25, 2020

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

Werner_E25-Diamond IAnswer
25-Diamond I
February 26, 2020

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

 

25-Diamond I
February 26, 2020

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_017-BedrockAuthor
7-Bedrock
February 26, 2020

Thank you very much FredLusk and Werner_E !

You both save may day.

Best regards,

Quinn