Decibels Engineers often measure the ratio of two power measurements in decibels
ID: 3808816 • Letter: D
Question
Decibels Engineers often measure the ratio of two power measurements in decibels, or dB. The equation for the ratio of two power measurements in decibels is dB = 10 log_10 P_2/P_1 where P_2 is the power level being measured, and P_1 is some reference power level. (a) Assume that the reference power level P_1 is I milliwatt, and write a program that accepts an input power P_2 and converts it into dB with respect to the 1 mW reference level. (Engineers have a special unit for dB power levels with respect to a 1 mW reference: dBm.) Use good programming practices in your program. (b) Write a program that creates a plot of power in watts versus power in dBm with respect to a 1 mW reference level. Create both a linear y plot and a log-linear plot.Explanation / Answer
1) Matlab code:
clc; clear all;close all;
p2 = input('Enter P2 in milliWatts');
p1 = 1;
dB = 10*log10(p2/p1);
fprintf('dB power level = %d', dB);
2)
Linear Plot Matlab code:
clc; clear all;close all;
x1 = input('Enter P2 in milliWatts first reading');
p1 = 1;
dB1 = 10*log10(x1/p1);
x2 = input('Enter P2 in milliWatts second reading');
dB2 = 10*log10(x2/p1);
x = [x1,x2];
y = [dB1, dB2 ];
plot(x,y,'o');
axis([0 (max(x) + 10) 0 max(y) + 10]);
xlabel('power in milliwatt')
ylabel('dB');
Log-linear plot Matlab code:
clc; clear all;close all;
x1 = input('Enter P2 in milliWatts first reading');
p1 = 1;
dB1 = 10*log10(x1/p1);
x2 = input('Enter P2 in milliWatts second reading');
dB2 = 10*log10(x2/p1);
x = [x1,x2];
y = [dB1, dB2 ];
plot(log10(x),y,'o');
axis([0 (max(log10(x)) + 10) 0 max(y) + 10]);
xlabel('Log(power in milliwatt)')
ylabel('dB');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.