Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...