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!