×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to get nearest element from List expression NX8.5 and higher

How to get nearest element from List expression NX8.5 and higher

How to get nearest element from List expression NX8.5 and higher

(OP)
Hi All,
I am trying to find the nearest number element from the given list of numbers. Imagine there are two expression1 and expression2 with data as mentioned below, the outcome I am expecting as expression3
Example:
expression1 = 140; (number type)
expression2 = {20, 25, 30, 40, 50, 80, 100, 125, 150, 200, 300, 500, 750, 1000} ; (list type)
expression3= 150 (number type)
It will be added value, if we can choose direction like floor, round and ceiling, so that I can pick 125, 150 looking forward for kind support.
Solution in NX8.5 to 11 is OK.

RE: How to get nearest element from List expression NX8.5 and higher

There are brute force ways to do this, I'm not so sure about built in functions to do this directly. Below are some of the functions that can be used. Not very clean but it will find the closest plus/minus.

a=2
list={abs(1-a),abs(2-a),abs(3-a),abs(4-a)}
b=minimum(list)
c=position(b,list)
d=nth(c,{1,2,3,4})

NX 11.0.1.11 Windows 10

RE: How to get nearest element from List expression NX8.5 and higher

In the Expression editor, there is a button "F(x)" that helps you enter math functions,the correct syntax, it contains a find function, type "floor" an press find, then step by step until you have the finished formula.
( maybe this wasn't what your last sentence asked for...)

Regards,
Tomas

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources