Find entropy of signal for overlapping ranges

1 visualización (últimos 30 días)
ALDO
ALDO el 5 de Sept. de 2020
Comentada: ALDO el 8 de Sept. de 2020
Hi
I would like to calculate entropy for the following array
P= 2987 2887 2999 2880 .... (cell array with 3867 elements, data is collected at 1 second interval)
i would like to calculate entropy for this array for the following elemets 1-10, 5-15, 10-20,15-25,... ( so basically every 10 seconds overlaping 5 seconds till end of array)
I wanted to used the following code but I dont know how to do the ranges. Thanks for your help in advance!
entropy= -sum(p*log2(P));
h1=histogram(your_signal, 'Normalization', 'Probability');
h1.Values;

Respuesta aceptada

Shubham Rawat
Shubham Rawat el 8 de Sept. de 2020
Hi ALDO,
You can form an two arrays of ranges which contain initial and final value of interval. Here is the reproduced code which you can refer:
initial = 0:5:3867; %initial values of intervals
initial(1) = 1;
final = 10:5:3867; %final values of intervals
Now you may calculate entropy of ranges like this:
for i = 1:length(final)
p = P(initial(i):final(i)); %values inside the interval i
results(i) = -sum(p.*log(p)); %calculate entropy of that interval
end
where results array contains entropy of each interval.
  1 comentario
ALDO
ALDO el 8 de Sept. de 2020
This worked perfectly! Thank you so much for your help!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by