Adding loop for a code
3 views (last 30 days)
I'm using the code from the link below
I need your help in modifing the code in the above link. I want to modify the code to add a loop for it. For example I have 2000 obervation and I need it to calcualte entropy for the first 120 obervation. Then it will take the next 120 obervation by leaving the first observation (1-lag). The output will be a vector of sample entropy.
Vimal Rathod on 30 Sep 2020
For making a bunch of iterations on the observation array you could directly loop through each element and call the "SampEn" function inside the loop and store the values in an array.
n = 2000; % number of observations
l = 120; % length of single set
observations = rand(1,n); % Consider this as observations
entropy = zeros(1,(n-l+1)); % initializing the entropy vector
for i = 1:(n-l+1)
% just included temporary values in the function.
entropy(i) = SampEn(observations(i:i+l-1),1,0.2);
Hope this helps.