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

Multiple input with units

SOLVED
Regular Member

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
Highlighted

Re: Multiple input with units

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
Highlighted

Re: Multiple input with units

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

Highlighted

Re: Multiple input with units

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

Highlighted

Re: Multiple input with units

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

 

Highlighted

Re: Multiple input with units

Thank you very much FredLusk and Werner_E !

You both save may day.

Best regards,

Quinn

Highlighted

Re: Multiple input with units

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.

Highlighted

Re: Multiple input with units

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