Find entropy of signal for overlapping ranges

1 vue (au cours des 30 derniers jours)
ALDO
ALDO le 5 Sep 2020
Commenté : ALDO le 8 Sep 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;

Réponse acceptée

Shubham Rawat
Shubham Rawat le 8 Sep 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 commentaire
ALDO
ALDO le 8 Sep 2020
This worked perfectly! Thank you so much for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by