I tried to use Position to get the Position of the 90% Maximum of a Photodiode Signal. The code works when i directly use the solution of the .9*Max[...] solution, but I want to have it with a Variable in Position. The problem is as long as i dont use the numerical value but some variable I get a empty solution {}

My code right now is:

Position[datapd[6][[All, 2]], nearest[datapd[6]]]

(* {} *)

which is not working while:

Position[datapd[6][[All, 2]], 0.566794]
(* {{735}} *)

is giving me the right result...

while datapd is my {time,voltage} list and nearest[datapd[6]] is my code giving me the 90% of my Voltage maximum. The code for nearest[...] is:

nearest[x_[nr_]] := Nearest[x[nr][[All, 2]], .9*Max[x[nr][[All, 2]]]]

which gives me for my datapd[6] list:


(* {0.566794} *)

I read something about Mathematica having Problems if the numbers of the Position input is somewhat different from the list element your looking for after some digits. But in my case the numerical value should be exactly the same.

I also tried using //N and also giving Position some condition with n_/;n==nearest[...] but it wont do the thing but just run and run.

Does somebody has any advices to fix this problem?

  • 2
    $\begingroup$ What about a short example data set? $\endgroup$ – Henrik Schumacher Aug 10 '18 at 14:35
  • $\begingroup$ Welcome to Mma.SE. Start by taking the tour now and learning about asking and what's on-topic. Always edit if improvable, show due diligence, give brief context, include minimal working example of code and data in formatted form. By doing all this you help us to help you and likely you will inspire great answers. The site depends on participation, as you receive give back: vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. $\endgroup$ – rhermans Aug 10 '18 at 14:41
  • $\begingroup$ I'm glad this solved your problem. Your question may be put on-hold as it seems to be off-topic, i.e it arises from a simple mistake and is unlikely to help any future visitors. Don't be discouraged by that cleaning-up policy. Your future good questions are welcome. Learn about common pitfalls here and don't forget the tour so you get a nice Informed badge. $\endgroup$ – rhermans Aug 10 '18 at 14:43


(* {0.566794} *)

Implies that Position[datapd[6][[All, 2]], nearest[datapd[6]]] searches for {0.566794} instead of 0.566794


Position[datapd[6][[All, 2]], First@nearest[datapd[6]]]
  • $\begingroup$ Thanks!! That did the job. $\endgroup$ – SBoles Aug 10 '18 at 14:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.