hi - official answer this time
the PSD concept is valid only for random type signals , not sinus
mathematically speaking, a sinus has a PSD of infinite amplitude and zero bandwith, simply because a sine wave has its energy concentrated only at one discrete frequency and not spread accross a wider freq range
if you test your code with random signals, you should see that the peak amplitude stays the same whatever the sampling frequency. But this does not hold if you test now with a sine wave
for a sine wave , the psd concept must be replaced by power or rms or peak amplitude
in summary , a FFT analyser will operate this way :
it will first compute the ftt.*conj(fft) power spectrum
if you ask for "PSD" (knowing that you are looking at random type signals) , it will do : PSD = power / nfft (as you did)
if you ask for "RMS" (knowing that you are looking at sine / multi sine type signals) , it will do : RMS = sqrt(power) and there is no division by nfft
so I modified a bit your code to test the different scenarios :
sf = 2200;
f = 440;
a = 0.5;
t = 0:1/sf:1;
x = a*randn(size(t));
sound(x,sf)
figure(1)
plot(t,x)
axis([0 1/f min(x) max(x)])
figure(2)
n = sf;
xhat = fft(x,n);
PSD = xhat.*conj(xhat)/n;
freq = 1/(1/sf*n)*(0:n);
L = 1:floor(n/2);
colormap jet(20)
plot(freq(L),PSD(L),'LineWidth',2.5)
6 Comments
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1268720
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1268720
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1269340
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1269340
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1270520
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1270520
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1270690
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1270690
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1270865
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1270865
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1271859
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719430-why-is-frequency-of-graph-differing#comment_1271859
Sign in to comment.