Find entropy of signal for overlapping ranges

조회 수: 1 (최근 30일)
ALDO
ALDO 2020년 9월 5일
댓글: ALDO 2020년 9월 8일
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;

채택된 답변

Shubham Rawat
Shubham Rawat 2020년 9월 8일
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
ALDO
ALDO 2020년 9월 8일
This worked perfectly! Thank you so much for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by