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 #68120] Tue, 06 October 2009 04:04 Go to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Oct 5, 6:26 pm, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:

> 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)

I think this is easier, and possibly faster:
Xidx = where((y-ytarget)*shift(y-ytarget,1) le 0, count)

The multiplication will only be negative if two points straddle the
crossing. The value 0 will be repeated twice if one of the points
matches exactly. These are easy to take out beforehand. The rest is as
before.

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

Maarten
[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: Sat Oct 11 11:56:59 PDT 2025

Total time taken to generate the page: 1.04047 seconds