MATLAB: How to convert the units of the y-axis into miliseconds^2/Hz in power spectral density analysis of an ECG signal

ecgpsdunits

This is the code that plots the PSD in dB/Hz on the y-axis
nfft = 2^nextpow2(length(ecg));
Pxx = abs(fft(ecg,nfft)).^2/length(ecg)/fs;
Hpsd= dspdata.psd(Pxx(1:length(Pxx)/2),'fs',fs);
p = plot(Hpsd);

Best Answer

The y-axis on a PSD estimate will not be in units of the time squared, it will be in amplitude squared per Hz, so for an ECG signal I assume that will be in millivolts, not milliseconds. The recorded values of the waveform are not in time.
Since you are using dspdata.psd, why not just use spectrum.periodogram?
psdest = psd(spectrum.periodogram,ecg,'NFFT',length(ecg),'Fs',fs);
plot(psdest)
If you want to plot without using dB (that is preferred by the way)
plot(psdest.Frequencies,psdest.Data)
Related Question