I am a borderline novice in Matlab.I am trying to write a rolling function of CMSE (Compose Multiscale Entropy) over a time series. I tried slidefun but that only works when the output is a scalar and the output for CMSE is a vector. The rolling window for the time series is supposed for 500 and the ouput of each windowed CMSE is a 100 x 1 vector. XX is the time series.
roll_CMSE_100=zeros(100,(length(xx)-499));
for i=1:(length(xx)-499)
roll_CMSE_100(i)=CMSE(xx(i:(499+i)),100)
end
I get the following output
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Thank you for your time and consideration
Matlab is telling you the problem: you are assigning to the element in position "X" a vector but should be a number, because roll_CMSE is a matrix. Or you use cell array or you make assignment correctly. If the output of CMSE(xx(i:(499+i)),100) is a 100x1 vector the correct way to assign the values is
roll_CMSE_100=zeros(100,(length(xx)-499));
for i=1:(length(xx)-499)
roll_CMSE_100(:,i)=CMSE(xx(i:(499+i)),100)
end
This simply assigns the ouput to column "i" of roll_CMSE matrix.