Entropy of an audio signal

16 views (last 30 days)
Ana
Ana on 13 Sep 2011
i am trying to find the entropy of an audio signal, so i need first the probability of appearance of each values of the signal, the problem is, i have this values due to the histogram i did but how can i get those values and save them into a vector in order to fins the entropy? i already have the entropy function!
function entro = entropia(x)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
x=[.5 .25 .125 .0625 .0625]; % these values must be the appearence probability of my signal values
tam=length(x); % tamaño del vector x
suma= 0;
for i=1:tam % hacer un for desde 1 hasta el tamaño del vector x
h= x(i)*log2(1/x(i)); % funcion de entropia
suma = suma+ h; % la suma acumula los valores obtenidos por cada valor del vector x
end
entro = suma;
coder.extrinsic('disp')
disp (entro);
end
please help!

Answers (1)

maria
maria on 25 Sep 2012
Maybe it's too later, but:
1. For extract probability use 'hist' function: p = hist(signal) or p = hist(signal, lengths)
2. Don't need that long code for entropy! I think it's wrong, because is 'log2(x(i))' and not 'log2(1/x(i))'. But really better you replace ALL and use only: -sum(p.*log2(p))
Good Luck!

Community Treasure Hunt

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

Start Hunting!