How to calculate gradient and correlation coefficients with moving window in matlab?

4 views (last 30 days)
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

Answers (0)

Community Treasure Hunt

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

Start Hunting!