Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi all,
As shown in the attached image,when tf=0.055 is equal to tf.min=0.055, the results should be "OK" since tf must be bigger or equal to tf.min as stated in the if statement
does anyone know why the calculation does not capture the equal sign and produce an "OK" output when the value of tf and tf.min are equal??
Thank you in advance.
Solved! Go to Solution.
Prime possibly is correct. Let the two vectors display with more than 3 decimals and I guess you would see that second entry in the first vector is slightly smaller than the corresponding element in the second vector.
If this does not matter for you because the values still are within an acceptable tolerance, lets say 10^-4, you could use t.f>=t.min-10^-4 instead of t.f>=t.min.
BTW, I guess it would be better to get rid of the third range argument "i." and call the check function vectorized. That way the result would be a true vector and not an invalid object which only can be displayed but not assigned to a variable.
If you need to use that kind of check more often in a sheet and don't like to have to vectorize the call every time, you may also do it that way:
As we can't vectorize the if-function directly it was necessary to use a local function f.
An alternative approach (as opposed to the tolerance variable) is to actually round the values in both vectors to the desired precision:
Personally I would not prefer that approach, though.
Never test for equality with floating point numbers. Set an acceptable tolerance level (e.g. tol = 10^-6) then replace the if test by something like :
if(abs(tf - tmin) >= tol, "OK", "NOT OK")
Prime possibly is correct. Let the two vectors display with more than 3 decimals and I guess you would see that second entry in the first vector is slightly smaller than the corresponding element in the second vector.
If this does not matter for you because the values still are within an acceptable tolerance, lets say 10^-4, you could use t.f>=t.min-10^-4 instead of t.f>=t.min.
BTW, I guess it would be better to get rid of the third range argument "i." and call the check function vectorized. That way the result would be a true vector and not an invalid object which only can be displayed but not assigned to a variable.
If you need to use that kind of check more often in a sheet and don't like to have to vectorize the call every time, you may also do it that way:
As we can't vectorize the if-function directly it was necessary to use a local function f.
An alternative approach (as opposed to the tolerance variable) is to actually round the values in both vectors to the desired precision:
Personally I would not prefer that approach, though.
Hi @NA_11204287,
I wanted to see if you got the help you needed.
If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation.
Thanks,