Resample Operation: Mismatch between "Nr of Points" and "/RATE"

Dear all,

I'm trying to understand the impact in sampling rate in my system and decided to run a quick simulation on Igor using data simulated at 10 kHz and subsampled at different rates. For this purposed i used <igor>Resample</igor> operation

//Resample the curve
Make/O /N=1000 SampleRates=P+1
Wave DataWave

Variable i
For(i=0; i<dimSize(SampleRates,0); i+=1)

    //Generate resampled wave
    Variable SamplingRate = SampleRates[i]
    Duplicate/O DataWave ResampledWave
    Resample /rate=(SamplingRate) ResampledWave
    String ResampledWaveName = "ResampledWave_"+num2str(SamplingRate)
    Duplicate ResampledWave root:ResampledData:$ResampledWaveName
   
EndFor

I clipped the original code to focus more on the problem, hope I did not leave out any relevant bit (seems understandable).

In attachment I try to illustrate the behavior of show the result of the resampling the data shown by a dotted line. When data is subsampled to 2Hz over 1 second it produces 2 datapoints as expected, but when is resampled at 3Hz it still continues to produce only 2 datapoints, albeit at different timepoints. 

The lower graph in attachment tries to illustrate how this difference between resampling frequency vs number of datapoints found in the generated resampled waves expands higher resampling frequencies.

Can anyone give me a hand with this? It is important that I actually do get a matching number of resampled datapoints to the resample frequency.

 

Many thanks,

R.

 

 

 

Attaching your entire experiment would be more helpful.

It is not clear (to me, at least) what your goal is.

I presume you know that undersampling data can lead to "aliasing" (Google is your friend, here).

In reply to by JimProuty

Hi Jim,

I can later attach the experiment, for now, simply my question is that if I sample my data at 3Hz for a dataset that spans over 1 second, I would expect to have datapoints for timepoints 0, 0.3333 and 0.66666 seconds. In my example however, for /Rate=3 I have only data for time points 0 and 0.333333 (so only 2 datapoints, not 3)

Hope I made a bit more clear my problem.

Best,

Ricardo

 

Hello everyone,

 

I attach above the procedure I am using when describing the problem earlier.

Essentially the procedure does the following:

  1. Generates a "data wave" for a single asymmetric pulse over a period of one second with 10k data points.
  2. Resamples the "data wave" for frequencies of 1 to 10kHz
  3. For each resampled frequency finds the difference between two points (unnecessary for the current problem).
  4. Counts the number of data points in each resampled wave and plots it against its resampling frequency.

So, in this example since the time period of the pulse is one second, I would expect the number of data points generated by the resample operation flagged with /rate=3 to be 3 data points, instead I get only two. Likewise, for /rate=6 I get only 5 points and this occurs throughout the entire frequency range.

If anyone could give an idea of what could be wrong here it would be very helpful.

Many thanks,

R.

ResamplingScan.ipf

I've fixed this (rounding) error for the next release of Igor 8 and for the next Nightly Build.

Look for a Build number >= 32973.

Sorry for the trouble.