Logarithmic summation of cell array

13 visualizaciones (últimos 30 días)
Karthik Brs
Karthik Brs el 29 de Oct. de 2015
Comentada: Stephen23 el 30 de Oct. de 2015
Hello everyone!
I currently have a 1*2 cell array. The cell array might also be additional fields. I have attached .mat file containing the variable with this query. The data in the given cell array contains the sound powers in 'db'. I am required to perform the logarithmic addition of all column vectors(100*1) in my cell array such that the resulting vector is of log. sum of all the column vectors, in my case(100*1). I am finding it difficult to perform this operation.
Thank you in advance!

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 29 de Oct. de 2015
Karthik - sometimes it helps to use the MATLAB debugger and step through the code to see what is happening at each line. Though trying to run the above fails immediately because of the way in which you are trying to iterate over the tempLW array. See http://www.mathworks.com/help/matlab/ref/for.html to understand how the for loop is constructed which would mean that your code would change to
for k=1:length(tempLw)
Using i and j as indexing variables are discouraged since they are also used by MATLAB to represent the imaginary number. Also, you are missing a bracket on your second line of code and so should be
TotalSoundPower = 10*log(sum(tempLw{k}));
Note also the braces used instead of brackets when accessing the column of data in the tempLW cell array.
So the above changes will get the code to work, but is the above really what you want? Do you want to sum all the decibel values from the first column and then do the 10*log10 on that sum? Is this giving you the value that you want? Then, what about the second column as you overwrite the TotalSoundPower from the first iteration of the loop?
  2 comentarios
Karthik Brs
Karthik Brs el 29 de Oct. de 2015
Hello Mr. Hayes, Thanks for the reply! I am not sure about how to add the decibel values. The code which I have included is the one which I found for excel. Would be glad if you can let me know the correct way to add the decibel value. All that I know is that I have to perform a logarithmic sum of decibel values as the decibel values cannot be added normally.
Karthik Brs
Karthik Brs el 30 de Oct. de 2015
The addition must be performed according to the equation as can be seen in the attached figure 'Formula.png'.
The 'L1' and 'L2' in the figure in my case represents the elements of cell array(column-wise). Please help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical 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