Problem using Position when using a variable [closed]

So,

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:

nearest[datapd[6]]

(* {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?

closed as off-topic by rhermans, m_goldberg, MarcoB, halirutan♦Aug 13 '18 at 15:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – rhermans, m_goldberg, MarcoB, halirutan
If this question can be reworded to fit the rules in the help center, please edit the question.

• What about a short example data set? – Henrik Schumacher Aug 10 '18 at 14:35
• 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. – rhermans Aug 10 '18 at 14:41
• 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. – rhermans Aug 10 '18 at 14:43

Given

nearest[datapd[6]]
(* {0.566794} *)


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

Try

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

• Thanks!! That did the job. – SBoles Aug 10 '18 at 14:42