首页 > 解决方案 > 如何在matlab中使用移动窗口计算梯度和相关系数?

问题描述

我正在研究行人步数检测算法(加速度数据),我需要从我的过滤信号而不是原始数据中计算统计特征。我已经计算了均值、var 和 std,现在我想从过滤后的数据中计算相关系数和梯度。我的过滤器数据是 1x37205 双倍。我使用 for 循环计算了这些特征,移动窗口大小 = 2samples 和前一个窗口的 50% 重叠。下面我附上我尝试过的代码。但是当我为 corrcoef 运行它时,它给出了 1 作为整个数据的输出,而对于梯度它给出了 error Assignment has more non-singleton rhs dimensions than non-singleton subscripts。我无法很好地理解。有人可以建议我或在 matlab 中提供任何代码帮助和/或我该如何处理?

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

标签: matlabmachine-learningaccelerometerfeature-selectionpearson-correlation

解决方案


推荐阅读