can someone explain to me what is this entire code means?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ptotdB = dbp(ptot);
in another file:
function y=dbp(x)
y = -Inf*ones(size(x));
nonzero = x~=0;
y(nonzero) = 10*log10(abs(x(nonzero)));
0 Kommentare
Akzeptierte Antwort
the cyclist
am 22 Mär. 2013
Bearbeitet: the cyclist
am 22 Mär. 2013
Looks like it's converting any non-zero input to decibels ( http://en.wikipedia.org/wiki/Decibel ), and zero input to negative infinity.
4 Kommentare
Walter Roberson
am 24 Mär. 2013
It depends what you mean by "declare". In order to use the function, you need to pass in an input value to the function, but the variable name you use in the calling function does not need to be named "x".
Weitere Antworten (1)
Ahmed A. Selman
am 24 Mär. 2013
This code finds log10 of the values of some vector (x). The line:
y = -Inf*ones(size(x));
is meaningless in this part of the code because it is overridden later by:
y(nonzero) = 10*log10(abs(x(nonzero)));
There could be more lines in this function that need the variable (nonzero). A much simpler code is:
function y=dbp(x)
y = 10*log10(abs(x(:)))';
2 Kommentare
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!