# How to avoid log10 from calculating for log values or if its calculated for complex log how do i avoid it?

4 visualizaciones (últimos 30 días)
Ganesh el 10 de Nov. de 2023
Editada: Stephen23 el 10 de Nov. de 2023
for example if code
log10(-3) i get
ans =
0.4771 + 1.3644i
but as we know log isn't defined for negative value. My objective is to calculate the correction factor for acoustic measurement the code is as follows and the how do i avoid this function calculating the log value of negative numbers.
% when delta is in the range of [-4,4];
delta=-10:0.1:10
K_factor=-(10*log10(1-10.^(-0.1*delta)))
%SPls=10*log10(10^(SPLt/10) - 10.^(K_factor./10))
plot(delta,K_factor)
xlabel("Delta Value");
ylabel("K Factor")
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Stephen23 el 10 de Nov. de 2023
Editada: Stephen23 el 10 de Nov. de 2023
"how do i avoid this function calculating the log value of negative numbers."
Don't call the function with negative values.
delta = -10:0.1:10;
V = 1-10.^(-0.1*delta);
X = V>0;
K_factor = nan(size(delta));
K_factor(X) = -10*log10(V(X));
plot(delta,K_factor)
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Simulation, Tuning, and Visualization en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by