Resample Issue

I have a question about using resample. If I make a 1D wave of length 50 (lets call it "wave"), go to Data>Resample, and resample "wave" using interpolate 51 and decimate 50, I get a new wave (call it "waveResampled"). However, "waveResampled" still contains 50 points, whereas one would expect that it would contain 51 points, since the number of points should be 50*(51/50)=51. This seems to happen whenever Interpolate and Decimate are nearly the same number... Obviously this isn't a huge problem, but I was kind of curious as to why it happens. Is it some kind of internal rounding issue?

Also, how do you change a graph background color? I was searching the manual but was unable to find it, although the manual is large, and I'm still new to Igor so it could be my fault for just not seeing it. I'd like to make graphs with black backgrounds.

Thanks!
Right-click in the graph margin. You'll get a contextual menu that includes color settings.

To do it programmatically, you would use the ModifyGraph operation.

I'll let someone else address the Resample question.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
DoopDeDoopDoop wrote:
I have a question about using resample. If I make a 1D wave of length 50 (lets call it "wave"), go to Data>Resample, and resample "wave" using interpolate 51 and decimate 50, I get a new wave (call it "waveResampled"). However, "waveResampled" still contains 50 points, whereas one would expect that it would contain 51 points, since the number of points should be 50*(51/50)=51. This seems to happen whenever Interpolate and Decimate are nearly the same number... Obviously this isn't a huge problem, but I was kind of curious as to why it happens. Is it some kind of internal rounding issue?


This is a classic "Fence-post error": If you interpolate a 50 point wave by, say a factor of 2, how many points do you get?

If you answered 100, then you're mistaken; the answer is 99. Look at the definition of the word "interpolate":

in·ter·po·late (n-tûrp-lt)
v. in·ter·po·lat·ed, in·ter·po·lat·ing, in·ter·po·lates
v.tr.
1. To insert or introduce between other elements or parts.
...
4. Mathematics: To estimate a value of (a function or series) between two known values.


So now you have 99 points, and you want to decimate by some factor that is not a divisor of 99, say a factor of 10.

How many points to you end up with? It is not 9.9. The answer is 9 points.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
I have a follow-up to this question. Is it possible to use the resample command to resample a wave to match, not just the RATE of another wave in the experiment, but to the same absolute values?

I have many waves of spectroscopic data, which for instrumental reasons have slightly different absolute x-values than one another (but, I believe, the same spacing between the values). In order to prep these data for analysis, I need them all to share a common axis, but since but each is correctly calibrated to itself, I cannot simply offset/shift the 'wrong-axis' data to match the 'right-axis' data. Is there a way to do this using resample? Or perhaps the interpolation command? Any help that avoids my having to fit the data and read out new traces for my 100+ spectra would be most appreciated!

Thanks!
If you choose an x0 and a dx, you can then create a wave, use SetScale to set the X scaling, and then Interpolate2 to set the Y values. Execute this for relevant details:
DisplayHelpTopic "Destination X Coordinates from Destination Wave"


This may also be of interest:
DisplayHelpTopic "Waveform Versus XY Data"


hrodstein wrote:
If you choose an x0 and a dx, you can then create a wave, use SetScale to set the X scaling, and then Interpolate2 to set the Y values. Execute this for relevant details:
DisplayHelpTopic "Destination X Coordinates from Destination Wave"



This was exactly what I needed -- thanks much for the tip!