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
Oleg Komarov 2012년 5월 29일
@Michel: correct the typo noted by per isakson.

댓글을 달려면 로그인하십시오.

답변 (1개)

per isakson
per isakson 2012년 5월 29일

0 개 추천

???
>> s.p = [32 35; 36 37 39]
Error using vertcat
CAT arguments dimensions are not consistent.

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2012년 5월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by