Reading the specific elements of a wave

Hello,

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
Quote:
I have been using Matlab for years and maybe it is for me quiet confusing how to work with wave form in Igor.


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.

Quote:
I want to read the last element of the wave and add one extra value (i.e., one minute) to that.


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:
Variable lastPoint = numpnts(w) // Get index of last point in wave
w[lastPoint] += 60

Sorry to correct you Howard, the last point is actually:
Wave w
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.
Quote:
Sorry to correct you Howard

Thanks for the correction. You are absolutely right!
One of the things I really like about Python/numpy slicing is that you can index the last point as w[-1], etc. It would be awesome if IGOR could slice like Python

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.
Hello all,

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
Hello again,

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
You could used the InsertPoints operation to instert a new point at the end of the wave. Here's the template for that operation:
InsertPoints [/M=dim ] beforeElement, numElements, waveName.

Another method was shown on the Igor mail list recently,

idx = DimSize(wMyWave,0)
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.
Hello all,

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
You can also add an extra value like this:
Make /O /N=3 jack=p
Edit jack
jack[3] = {3}