Skip to content
Advertisement

How to find points of the x axis corresponding to the values of y equal to some value

I have a sine signal defined by two lists

enter image description here

and I want to know the points of conductance (s) at which the voltage is 0.5.

I did it wit this code: voltage = [...] conductance = [...] edges = [] for n in voltage: if n == 0: pass elif voltage[n] > 0.5 and voltage[n-1] < 0.5 : edges.append(conductance[n]) elif voltage[n] < 0.5 and voltage[n-1] > -35. : edges.append(conductance[n])'

Is there a better or more precise way of doing it? Maybe using some numpy function? Or by intersecating with a horizontal line?

Advertisement

Answer

Your sine signal appears noisy, as if you have collected it from a real source with some natural error. One way to find the value would be to interpolate linearly between the two nearest points, assuming your test point did not fall precisely on a real point (which is unlikely in practice). Another option would be to fit a sine wave to your noisy data and use the resulting function to generate the data you want.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement