I have some experimental data from a shaker (vibration exciter) running at sine $10\textrm{ Hz}$ for test purposes (recorded using an ADXL345 accelerometer with $f_s=512\textrm{ Hz}$. I would like to upsample these data for varies ratios, e.g. a factor of $\times 10$. How do I update the FFT in MATLAB accordingly? As of now, upsampling appears to shift results in the $x$-direction as shown in the figure below (black is the original signal, blue is the resampled signal with cutoff at $1/2\times f_s$):
Peak at approximately 80 Hz (black) appears at approximately 40 Hz (blue).
But I would like to increase the resolution within the existing data without shifting results in the $x$-direction?
MWE:
close all; clear all; clc
fs=512; % sampling frequency
load data.mat
t=X{1}; % time
y=X{4}; % accelelation
y=y./1024; % calibration of data
%% resampling
%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
ups=10; % upsampling rate
%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
dns=1; % downsampling rate
fu = fs*ups; % upsampling frequency
% tu = t(1):1/fu:t(end)-1/fu;
ytu=resample(y,ups,dns);
%% FFT and plot
figure;
x=y;
[N,m] = size(x);
freq = 0:fs/length(x):fs/2; %frequency array for FFT
xdft = fft(x); %Compute FFT
xdft = 1/length(x).*xdft; %Normalize
xdft(2:end-1) = 2*xdft(2:end-1);
semilogy(freq,abs(xdft(1:floor(N/2)+1)),'k-')
hold on
x=ytu;
[N,m] = size(x);
freq = 0:fu/length(x):fu/2; %frequency array for FFT
xdft = fft(x); %Compute FFT
xdft = 1/length(x).*xdft; %Normalize
xdft(2:end-1) = 2*xdft(2:end-1);
semilogy(freq,abs(xdft(1:floor(N/2)+1)),'b.')
xlabel('Frequency (Hz)');
ylabel('Accel (g)');
grid on;
Here is the link to data.mat.
resample
applies a lowpass filter to your data. Why not interpolate between accel samples? $\endgroup$