%% Decibels from Voltage and Power
% Express a unit voltage in decibels. Assume that the resistance is 2 ohms. Compare the answer to the definition, 10\log_{10}\frac{1}{2}.

V = 1;
R = 2;
dboutput = db(V,2);
compvoltage = [dboutput 10*log10(1/2)]

%
% Convert a vector of power measurements to decibels. Compare the answer to the result of using the definition.

rng default
X = abs(rand(10,1));
dboutput = db(X,'power');
comppower = [dboutput 10*log10(X)]

% Copyright 2012 The MathWorks, Inc.