1

I plotted this spectrum with the following code:

PSD plot

[Y,F]=psd(samples, NFFT=1024, Fs=sdr.sample_rate/1e6, 
Fc=sdr.center_freq/1e6, noverlap=0)
xlabel('Frequency (MHz)')
ylabel('Relative power (dB)')           
max=np.max(Y)
print(max)

but then I get

max=0.000458510518667

Actually, if I print the values of Y, I get:

[ 8.60400008e-06 7.85361760e-06 9.00300444e-06 ...,
9.55738417e-06 1.14888955e-05 1.12340323e-05]

maybe I need to do something else to get the amplitudes that I see in the plot?

1 Answers1

1

The result isn't given in dB so actually:

10*log(0.000458) = -33 dB (approx.)

Therefore, the previous code is correct and you can use it if you need to get the maximum value of the PSD function. You could add this code:

    max=np.max(Y)
    log=10*math.log10(max)
    print(max)
    print(log)

I realize about this thanks to the user @ImportanceOfBeingErnest who is an expert in the Python library I'm using, matplotlib.