comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to calculate the abscissa values for the given vertical values
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to calculate the abscissa values for the given vertical values [message #68126 is a reply to message #68124] Mon, 05 October 2009 09:26 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
duxiyu@gmail.com wrote:
> Y is a time series and X is the sampling time.
> Both X and Y are discrete.
> I don't know the analytical form of the relation bewteen X and Y.
>
> To get the vertical value NY for a given time NX, I can use 'NY =
> interpol(Y, X NX)'.
> Similarly, I want to get the correspondent time CX for a fixed
> vertical value CY.
> But the values of correspondent time are not unique. CX should be not
> a scalar but an array.
> So I cannot use 'CX = interpol(X, Y, CY)' to get these values.

You may do it by hand...

x = findgen(1000)/1000*4*pi
y = cos(x)

Ytarget = 0


;Find the 2 consecutive points that are > and < of the Y threshold value
;(don't forget to deal where a point = the value)

Xidx = where((y gt Ytarget and shift(y,1) lt Ytarget) or (y lt Ytarget
and shift(y,1) gt Ytarget), count)


then you can do a linear interpolation to find Xsolution

;y = ax+b
a = (y[xIdx] - y[xIdx+1]) / (x[xIdx] - x[xIdx+1])
b = y[xIdx]-a*x[xIdx]
Xsolution = (yTarget - b)/a

Jean
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Earn Free cash From DoEarn
Next Topic: rois

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 16:36:39 PDT 2025

Total time taken to generate the page: 0.39610 seconds