How can I plot in dB in Matlab?

120 views (last 30 days)
Joel Ruiz
Joel Ruiz on 31 Aug 2020
Answered: Peter O on 31 Aug 2020
Hello:
I am working on app designer. My app is about communications and I need to plot the frequency response of a mixer. However, the levels of signal power I'm using are lower than a reference, so I need to plot some negative amplitude levels in dB.
In the real life I need to obtain this:
but in Matlab I don´t know how to plot those negative values.
The code I'm using is this:
function spectrum(app)
%For sin signal and AM
if app.SinButton.Value == true && app.AmplitudeModulationButton.Value == true
[fc,A,Ap,fm,Fs,Ts,N,t,f,mi,Vcdol,Vcdif] = getdata(app);
x = Vcdif+A*sin(2*pi*fm*t); % IF
p= Vcdol+Ap*sin(2*pi*fc*t); % carrier signal
y=((1+mi*x).*p); %modulated signal
plot(app.UIAxes,f,10*log10(abs(fftshift(fft(y))));

Answers (1)

Peter O
Peter O on 31 Aug 2020
Decibels are a ratiometric measurement. For power, as shown in your plot, the reference is 1 milliwatt (denoted from the dBm). 0dBm means that the ratio is 1.0. If you've only got 0.5 mW output, then the ratio is 0.5e-3/1e-3 =0.5.
PdBm = 10*log10(0.5) = -3dBm.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!