Reading the specific elements of a wave
tooprock
I have been using Matlab for years and maybe it is for me quiet confusing how to work with wave form in Igor. What I am trying to do is:
I have a wave which contains the time values in dd/mm/yyyy hh/mm/ss form. I want to read the last element of the wave and add one extra value (i.e., one minute) to that.
01.01.2001 00:00:15
01.01.2001 00:30:00
...
...
...
01.09.2001 00:00:00 // This is the last element
01.09.2001 00:00:01 // Symbolic value
Thanks for any suggestion
Cheers,
Emre
I highly recommend doing the first half of the Igor guided tour. This is really an essential introduction and will save you a lot of time and frustration. Choose Help->Getting Started. If you prefer video tutorials see http://www.wavemetrics.com/products/igorpro/videotutorials.htm.
I presume your data is in Igor date/time format as it would be if you loaded it from a data file using LoadWave. Igor stores date/time data as seconds since 1904-01-01. Thus you can add one minute by adding 60 seconds. So:
w[lastPoint] += 60
November 2, 2012 at 10:08 am - Permalink
variable lastpoint = numpnts(w) - 1
w[lastpoint] += 60
Whilst numpnts(w) would work it leads to further problems down the track, with 'off by one' errors. tooprock, IGOR indexes from 0.
November 3, 2012 at 09:35 pm - Permalink
Thanks for the correction. You are absolutely right!
November 3, 2012 at 10:59 pm - Permalink
The following would make a new wave, x, which consisted of elements 0, 2, 4, 6, 8.
x= w[0:10:2]
The following would make a new wave, x, which was reversed from w:
x = w[::-1]
etc.
November 4, 2012 at 07:09 pm - Permalink
Thank you so much for your suggestions. I actually have done almost all of the introduction (maybe more than two times). However, I am still confused sometimes about the syntax. I understood, what I am doing actually wrong. Thanks again.
Cheers,
Emre
November 5, 2012 at 04:48 am - Permalink
What you have suggested didn't work because I don't want to change the last point but I want to add one extra point and give a symbolic value to that. Like:
01.01.2001 00:00:15
01.01.2001 00:30:00
...
...
...
01.02.2001 00:00:00 // This is the last element. So, I don't want to change this. I just want to add extra point, which is the next line
01.02.2001 00:01:00 // For instance, I added here one minute to the previous value
Cheers,
Emre
November 12, 2012 at 06:25 am - Permalink
InsertPoints [/M=dim ] beforeElement, numElements, waveName.
Another method was shown on the Igor mail list recently,
wMyWave[idx] = {vNewValue}
idx is the index for the point you wish to add. In this case you're simply adding one more point, so we can get that point value from the DimSize function. This works because wave indices are zero based. Note that curly braces surround the new value, this is necessary. Without them, you will only overwrite the last existing element in the wave, not add an additional element. I haven't searched the help docs to see if this is a supported or unsupported feature, which, thus, may or may not change in the future.
November 12, 2012 at 06:44 am - Permalink
I managed to do that. Here is my solution:
LoadWave/J/D/A=Time_Wave/O/K=0/L={0,1,0,0,0}/R={English,2,2,2,2,"DayOfMonth.Month.Year",40} "" // The wave which contains my time data in Igor Time format.
Duplicate/O Time_Wave0, T_Wave
Variable lastpoint = numpnts(T_Wave) -1 //
Variable lastvalue = T_Wave[lastpoint] // We read the last value
Variable pointvalue = lastpoint+1 //
InsertPoints pointvalue,1, T_Wave // Add one extra point to the wave
T_Wave[pointvalue] = lastvalue+60 // Assign the value for added point
It's all.
Thanks for your comments.
Cheers,
Emre
November 12, 2012 at 06:50 am - Permalink
Edit jack
jack[3] = {3}
November 12, 2012 at 09:59 am - Permalink