Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resampling of two data sets of different length in MATLAB

I have two vectors: sensorA of length 927 and sensorB of length 1250. I would like to make them of the same length. The resample() function in MATLAB is very noisy at the edges and I need atleast reasonably good accuracy throughout.

I understand that resampling can be done by interpolation, but how do I implement it in the most efficient way. I need to stretch 927 to 1250 as uniformly as possible.

I was wondering if I could do something like this:

  1. I need 333 new samples in the shorter vector. So for every 3 values, I insert the average (midpoint) of two consecutive values in between then. => 309 samples inserted
  2. For the remaining I insert again for every 38 samples (927/(333-309))

Does this make sense? I still won't be able to get an exact interpolation. Is there any other function that I could use? (besides interp() because it requires an integral resampling rate?)

like image 245
Imelza Avatar asked Feb 15 '11 03:02

Imelza


People also ask

How do you resample non uniform data in Matlab?

y = resample(x,p,q) resamples the input sequence, x, at p/q times the original sample rate. If x is a matrix, then resample treats each column of x as an independent channel. resample applies an antialiasing FIR lowpass filter to x and compensates for the delay introduced by the filter.

How do you resample time series data in Matlab?

Description. tsout = resample( tsin , timevec ) resamples a timeseries object tsin using a new time vector timevec . The resample function uses the interpolation method associated with tsin , which you can display using the command getinterpmethod(tsin) .

What does resampling do in Matlab?

The resample function performs rate conversion from one sample rate to another. resample allows you to upsample by an integral factor, p , and subsequently decimate by another integral factor, q .

How do you plot resample in Matlab?

y = resample( x , tx , fs , p , q ) interpolates the input signal to an intermediate uniform grid with a sample spacing of ( p / q )/ fs . The function then filters the result to upsample it by p and downsample it by q , resulting in a final sample rate of fs .


1 Answers

From a signal-processing view, you should NOT just insert a sample every 3 values. That would be non-uniform stretching and would ruin your signal. The resample function is what you want. Try changing the parameters for n and/or beta. You may need to pad your signal as described here to reduce the edge effects.

like image 95
k107 Avatar answered Nov 17 '22 01:11

k107