mag2db
Computes magnitude from decibels (dB).
Syntax
YDB = mag2db(Y)
Inputs
- Y
- A matrix.
Outputs
- YDB
- A matrix
Examples
A = [10 51;4 -1.2];
r1 = mag2db(A)
r2 = mag2db(1)
r1 = [Matrix] 2 x 2
20.00000 34.15140
12.04120 NaN
r2 = 0
sys.num=[0 0 0 1]; % Numerator coefficients
sys.den=[1 5 6 0]; % Denominator coefficients
w=logspace(-2,2,100); % Frequency
magnitude=1./(w.*sqrt(w.^2+3^2).*sqrt(w.^2+2^2)); % Magnitude expression
mag_db=mag2db(magnitude) % Magnitude in dB
semilogx(w,mag_db);
xlabel('Frequency');
ylabel('Magnitude [dB]');
mag_db = [Matrix] 1 x 100 Row[1] Columns[1:6]
24.43682 23.62871 22.82059 22.01246 21.20432 20.39617
-- (f)orward, (b)ack, (q)uit, (e)xit, (↑), (↓), (←), (→)
Comments
YDB = mag2db(Y) computes the decibel (dB) value YDB for a magnitude Y.
The formula used to convert between magnitude and decibels is ydb = 20 * log10(y).
Negative values of Y are mapped to NaN.