📄 db.m
字号:
function y = dB( x, dBrange, dBmax )%DB convert an array to decibels%-- % Usage: Y = dB( X, dbRANGE, dbMAX )%% will compute 20 Log(X)% and then scale or clip the result so that% the minimum dB level is dbMAX-dbRANGE.% ex: db(X, 80, 0) gives the range 0 to -80 dB%% Y = dB( X, dbRANGE ) defaults to dBmax = 0%---------------------------------------------------------------% copyright 1994, by C.S. Burrus, J.H. McClellan, A.V. Oppenheim,% T.W. Parks, R.W. Schafer, & H.W. Schussler. For use with the book% "Computer-Based Exercises for Signal Processing Using MATLAB"% (Prentice-Hall, 1994).%---------------------------------------------------------------if dBrange<=0 error(' min dB is max dB minus dBrange')endif nargin == 2 dBmax = 0; endy = abs(x);ymax = max(y)/10.0^(dBmax/20);if size(x,1)==1 y = y/ymax;else for i=1:size(y,2) y(:,i) = y(:,i)/ymax(i); end % scale all columns, unless x is row vectorend thresh = 10.0^((dBmax-dBrange)/20);y = y.*(y>thresh) + thresh.*(y<=thresh);y = 20.0*log10(y);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -