Hi Ray,
Your data are:
amplitude=[0.707 0.694 0.703 0.699 0.694 0.686 0.686 0.706 0.713 0.719 0.704 0.69 0.697 0.702 0.705 0.687 0.684];
t=[0.707 1.401 2.104 2.803 3.497 4.183 4.869 5.575 6.288 7.007 7.711 8.401 9.098 9.8 10.505 11.192 11.876];
The vector t values are non-uniformly spaced in time. I see two options how to calculate PSD:
1) You can use the Matlab function 'interp1' to interpolate data on uniform time grid and then apply the function 'fft' or any other Matlab function that calculates PSD. Code example:
T_mean=(t(length(t))-t(1))/(length(t)-1); %Calculate mean sampling period
amplitude_i=interp1(t,amplitude,t(1):T_mean:t(length(t))); %Interpolate data on uniform time grid
Psd_i=abs(fft(amplitude_i)).^2/(length(t)*T_mean); %Calculate PSD of interpolated data
semilogy(Psd_i); %Plot PSD on log scale as PSD has a large peak on zero frequency
2) Another option is to use the function 'nedft' downloadable on fileexchange:
https://se.mathworks.com/matlabcentral/fileexchange/11020-extended-dft
This function allows you to calculate the PSD directly from the non-uniform data (amplitude and t vectors) without interpolating them to uniform grid. Let me known if you are interested in applying it.
Best Answer