How does resample exactly work?
35 views (last 30 days)
Show older comments
Hi,
I try to find out, what resample is exactly doing.
Therefore, I calculate the filter coefficients with resample.
Then, I construct a constant signal and calculate the steady state zi with the filter, the constant signal and the filter coefficients. After that, I use the filter with the data and zi to get the filtered signal.
I assumed, that the filtered signal and the resampled signal should be the same, but it is not the case. What do I wrong?
[y,b] = resample(data', 1, factor);
const_signal = data(1)*ones(1,length(b));
[~,zi] = filter(b,1.0,const_signal);
x = filter(b,1.0,data,zi);
x = x(1:factor:end);
In this code, x and y are not the same. But I do not understand, why?
Best regards :)
0 Comments
Answers (1)
Mathieu NOE
on 17 Nov 2020
hello
everything is explained if you type help resample
resample Resample uniform or nonuniform data to a new fixed rate.
Y = resample(X,P,Q) resamples the values, X, of a uniformly sampled
signal at P/Q times the original sample rate using a polyphase
antialiasing filter. If X is a matrix, then resample treats each
column as an independent channel.
have you tried the examples ?
% Example 1:
% Resample a sinusoid at 3/2 the original rate.
tx = 0:3:300-3; % Time vector for original signal
x = sin(2*pi*tx/300); % Define a sinusoid
ty = 0:2:300-2; % Time vector for resampled signal
y = resample(x,3,2); % Change sampling rate
plot(tx,x,'+-',ty,y,'o:')
legend('Original','Resampled');
xlabel('Time')
% Example 2:
% Resample a non-uniformly sampled sinusoid to a uniform 50 Hz rate.
Fs = 50;
tx = linspace(0,1,21) + .012*rand(1,21);
x = sin(2*pi*tx);
[y, ty] = resample(x, tx, Fs);
plot(tx,x,'+-',ty,y,'o:')
legend('Original','Resampled');
xlabel('Time')
0 Comments
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!