Accuracy of resampling for decreasing vector size

9 views (last 30 days)
I'm wondering if anyone knows exactly how the resampling function works? I'm using it to decrease/reshape the size of my vector from 1473 to 1400, but I want to make sure the values in each column are still the mean of the data I'm compressing into the vector. I tried using this to decrease another vector from ~19000 to 1400, but ended up with almost all NaN's, so I am now questioning what it is really doing.
I would appreciate any insight you might have!
This is how im using resampling for the shorter vector:
Dat(1,:)=resample(A,1400,1473);

Accepted Answer

Star Strider
Star Strider on 2 Jun 2020
Use the method argument to determine how the resampled vector is created.
I have no idea how the other resample call returned ‘almost all NaN"s’, since you did not provide it.
One option is to define the sampling frequency ‘Fs’ as:
t = linspace(min(v_19000), max(v_19000), 1400)
Fs = 1/mean(diff(t));
or use ‘t’ with the techniques descriibed in: Resample a Nonuniformly Sampled Data Set, or similar approaches.
I’ve never had problems with resample, however I cannot determine what you’re asking it to do.
  2 Comments
Vanessa Yau
Vanessa Yau on 3 Jun 2020
Edited: Vanessa Yau on 3 Jun 2020
I have a vector 1x19530 and each data point is taken every few seconds, I wanted to use resample to fit this vector into a 1x1400 vector by averaging the data points, but I'm not sure if I was using it correctly (or if there is an easier way to do this?).
Star Strider
Star Strider on 3 Jun 2020
The resample function is correct, since it incorporates an anti-aliasing filter. If you are unsure of the sampling intervals, use the approach in the link I already posted with respect to resampling a non-uniformly sampled data set. I also illustrated a way to calculate the time vector and (if necessary) the sampling frequency. That should give you enough to allow you to resample your vector to a shorter length.
Note that the result may not be what you want, unless the original sampling frequency significantly oversamples the waveform you are recording, so that it does not lose appreciable detail when reduced to 0.072 of its original length.
So be aware that what you want to do may not be possible to do, if that condition does not apply to your signal.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!