matlab - 如何在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
解决方案
推荐阅读
- django - Django:在模板中显示相关项目的总和
- java - Firebase onComplete 从未在 Android 10 中调用
- node.js - 如何从 GCP 授予 Firebase Functions 访问资源的权限?(如 GCE)
- javascript - Mongo 块未写入
- java - GCP 机器映像 - 获取项目的映像列表
- css - 如何在 wordpress 主题中更改网站标题字体样式 Bizberg Consulting Dark
- javascript - 将id传递给jquery函数
- erlang - 了解 Erlang 列表理解生成器
- amazon-web-services - AWS 网络访问控制列表在哪个 OSI 层运行?
- python - 如何在 Tkinter 中将与 .trace 一起使用的输入字段设置为自动完成但所有字母都转换为小写