Working with structures
이전 댓글 표시
I have a n-by-1 structure array s with fields p and q. Each field contains a different number of elements, but fields of same index have the same number of elements. Specifically, numel(s.p{i})=numel(s.q{i}).
I would like to calculate two things. First, a 1-by-max(numel(s.p{i})) vector with the column means of s.p. Second, a vector of same size with the column means of s.q, but considering nonexistent elements as zero. For example, suppose s.p and s.q are: s.p = [32 35; 36 37 39] and s.q = [100 150; 120 170 180].
I would like to obtain: mean(s.p) = (34 36 39) and mean(s.q) = (110 160 90).
Any help? Thanks in advance.
댓글 수: 1
Oleg Komarov
2012년 5월 29일
@Michel: correct the typo noted by per isakson.
답변 (1개)
per isakson
2012년 5월 29일
???
>> s.p = [32 35; 36 37 39]
Error using vertcat
CAT arguments dimensions are not consistent.
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!