How can I plot in dB in Matlab?
49 views (last 30 days)
Show older comments
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/354257/image.png)
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))));
0 Comments
Answers (1)
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.
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!