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
Hello,
How can I fix this file in order that the multiple input to work with units?
Thank you
Solved! Go to Solution.
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:
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:
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):
Thank you very much FredLusk and Werner_E !
You both save may day.
Best regards,
Quinn
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: