Group Abstract Group Abstract

Message Boards Message Boards

0
|
6K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

A problem with functions Flatten; Position; Nearest

Posted 11 years ago
3 Replies

Try something like this (using Daniel's suggestion):

nearestIndex[list_, a_] :=
  Nearest[list -> Range[Length[list]], a][[1]];

{pos5 -> nearestIndex[m5, a],
 pos6 -> nearestIndex[m6, a]}

To get the position(s) you can use Nearest[values->Range[Length[values], a]. That should allow you to avoid Position. No idea why Flatten is needed without seeing your actual example.

POSTED BY: Daniel Lichtblau
Posted 11 years ago

If you could edit your posting to include a small example with all the data, what the solution should be and why then it might be more likely that you would get good answers more quickly.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard