I'm trying to use the resample function, and I've found the following in the document of MATLAB signal processing toolbox (https://www.mathworks.com/help/signal/ref/resample.html#d117e155565):
- y = resample(x,tx,___,method) specifies the interpolation method along with any of the arguments from previous syntaxes in this group. The interpolation method can be 'linear', 'pchip', or 'spline'.
The following is my code:
clear;
a = [1, 2, 3, 2, 0.5]; %original signal
tx = [0, 1, 2, 3, 4];
fs = 20; % resample frequency
[a_rs, ty] = resample(a, tx, fs, 'linear');
plot(tx, a, 'o', ty, a_rs, '.');
legend('original', 'resampled');
What I got is the following figure:
resampled signal vs original signal
Obviously it was not 'linearly' interpolated from the original signal. Instead, it seems a low pass filter was applied. Can anyone tell me what's wrong here? Thanks a lot?