Correct index
max2331
I'm new to Igor and have a problem I can't solve.
I have three Waves Time, Latitiude and Longitude.
Now I want to write function that gives me the lat and lon values for a specific time.
i tried it this way but latlist is empty.
Please help me.
Max
#pragma rtGlobals=1 // Use modern global access method.
Function/D search(x1, x2)
Variable x1,x2
Variable x3,x4
Wave LAT
Wave TIMEW
Wave LON
x3=TIMEW(x1)
x4=TIMEW(x2)
Extract/O LAT,latlist,LAT=x3 && LAT=x4
Function/D search(x1, x2)
Variable x1,x2
Variable x3,x4
Wave LAT
Wave TIMEW
Wave LON
x3=TIMEW(x1)
x4=TIMEW(x2)
Extract/O LAT,latlist,LAT=x3 && LAT=x4
You are asking for the value of TIMEW where its x value equals x1 but its x values are in terms of point number by default. To understand this execute:
If you are looking for the point number at which TIMEW hits x1 then you need to use FindLevel.
This is incorrect:
To check for equality use ==, not = which does assignment.
I think a different approach would be easier but I don't know if it will get you where you want to go. Assuming that timew is monotonic you can use the interp function to get a linearly interpolated value for a given time:
Print interp(<some time value>, timew, lon) // Print interpolated longitude
January 27, 2013 at 10:56 am - Permalink
I have a file from a flight. In this file I've got the time in seconds, latitude, longitude and altitude. Every thing in a seperate wave.
Now I want for a specific time that Igor gives me the latitude longitude and altitude corresponding to this time.
So I need the point of the time and than I have to tell Igor that I want the corresponding values from the other waves.
Somehow I don't get findlevel to work right.
I would be glad if someone could help me!
January 28, 2013 at 05:16 am - Permalink
You could use findvalue on the time wave to get the point number at which that time value occurs, then use this point number to get the lattitude and longitude.
variable x1
Wave TIMEW
WAVE LAT
WAVE LON
findvalue/v=x1 TIMEW //search time wave for the value of 40 (i'm assuming 40 seconds into flight)
//point saved in V_Value, if not found, V_Value = -1... you can add some logic to check for this
print LON[v_value]
print LAT[V_Value]
end
January 28, 2013 at 09:15 am - Permalink
DisplayHelpTopic "The Waveform Model of Data"
DisplayHelpTopic "SetScale"
January 28, 2013 at 10:51 am - Permalink
What is wrong with interpolating? Perhaps it's not clear from Howard's answer, but using the interp function (or setting the wave scaling) will return exact values of data in your Lat and Long waves as long as the user inputs an exact time value that is in your time wave. The issue you should think about is what should happen if a nonexistant time value is input. I.E. you have data at 40 seconds and 50 seconds, but I call your function for a time of 43 seconds. Interpolating 30% of the way between 40 and 50 seconds is a common and valid approach (and what is done implicitly whenever data is graphed with lines instead of markers), but if it seems misleading to give the user an answer for a time that falls between data points, than what should happen? Should it be coerced to the nearest real data point or should the function indicate an error? To coerce to the nearest point you can use
ActualTime = TimeWave[pointnumber]
ActualLatitude = LatitudeWave[pointnumber]
ActualLongitude = LongitudeWave[pointnumber]
But if you do that you should also probably indicate to the user that you're giving an answer for ActualTime rather than the time they asked for. In this case too, if the user inputs an exact time value, they get an exact answer (ActualTime == InputTime).
January 29, 2013 at 09:02 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 29, 2013 at 10:07 am - Permalink