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 个)

???
>> 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