I am working on pedestrian step detection algorithm (acceleration data), i need to calculate statistical features from my filtered signal not raw data. I have already calculated mean, var and std and now i want to calculate correlation coefficients and gradient from filtered data. My filter data is of 1x37205 double. I calculated these features using for loop with moving window size=2samples and 50% overlap of previous window. Below i am attaching the code i tried with to calculate. But when i run this for corrcoef it gives 1's as output for whole data and for gradient it gives error "Assignment has more non-singleton rhs dimensions than non-singleton subscripts". I am unable to understand well. Could some one suggest me or provide any code help in matlab and/or how can i work on that?
windowsize=2;
%%C is used for corrcoef and G for gradient. %%Data_filtered is caclulated
%%from acceleration xyz.
function [C, G] = features(Data_filtered, window)
C=zeros(length(Data_filtered),1);
G=zeros(length(Data_filtered),1);
for i=window:(length(Data_filtered))
C(i,1)=corrcoef(Data_filtered(i+1-window:i));
end;
for i=window:(length(Data_filtered))
G(i,1)=gradient(Data_filtered(i+1-window:i));
end;
end
question from:
https://stackoverflow.com/questions/65904047/how-to-calculate-gradient-and-correlation-coefficients-with-moving-window-in-mat 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…