Averaging multiple structures of different lengths
1 次查看(过去 30 天)
显示 更早的评论
Hello,
Here is my error message:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error using sum
Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Here is the script through which I am receiving this message:
a=calc_splitbelt('CSB_YA001_control0008', slowleg)
b=calc_splitbelt('CSB_YA001_control0009',slowleg)
(This produces a as a 1x1 with 14 fields, and b as a 1x1 structure with 14 fields).
Then, I want to take the average StepLengthSym (one of the fields) of both a and b, so my script continues with
c=[a.StepLengthSym b.StepLengthSym]
Avgc=mean(c)
a.StepLengthSym and b.StepLengthSym are different lengths, which I know is what is producing the horzcat error.
Is there a way I can edit this to make it so that I am able to take the average StepLengthSym for both a and b even though those fields are different lengths? TIA
0 个评论
采纳的回答
Voss
2022-2-18
This will combine a.StepLengthSym and b.StepLengthSym into a single column vector c that you can then take the average of:
c = [a.StepLengthSym(:); b.StepLengthSym(:)];
Avgc = mean(c);
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!