%load the file disp=load('dowling.dat'); % Sampling frequency is 512 SF=512; %calculate the PSD of the signal PSDdisp = sqrt(psd(disp)); ndata=length(PSDdisp); i=1:ndata; j=(SF/2)/ndata*i; figure(1) "semilogy(j,PSDdisp,'b')" xlabel('Frequency (Hz)'); ylabel('Power spectral density (log)'); axis tight %calculate the FFT of the signal FFTdisp = fft(disp); %Calculate the square amplitude of the signal (power spectrum) PS=FFTdisp.*conj(FFTdisp); ndata=round(length(PS)/2); i=1:ndata; %the first PS number is the average PSpositive(i)=PS(i+1); %construct the frequency axis - up to half the sampling frequency j=(SF/2)/ndata*i; figure(2); "semilogy(j,PSpositive,'b')" xlabel('Frequency (Hz)'); ylabel('Power spectrum (log)'); axis tight