summaryrefslogtreecommitdiff
path: root/macros/mag2db.sci
blob: 8ab0f69db5d8c37695a3fd9a79b182e252e1559d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

function [ydb] = mag2db(y)
//The relationship between magnitude and decibels is ydb = 20 log10(y).
//ydb = mag2db(y) expresses in decibels (dB) the magnitude measurements specified in y. 
//Author 
//Debdeep Dey

    funcprot(0);

    ydb(find(abs(y)>0))= 20 * log10(y(find(abs(y)>0)));
    ydb(find(real(y)<0))=%nan;
    ydb(find(y==0))=-%inf;
    ydb=matrix(ydb,size(y));
        

endfunction