Working with structures
Show older comments
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 Comment
Oleg Komarov
on 29 May 2012
@Michel: correct the typo noted by per isakson.
Answers (1)
per isakson
on 29 May 2012
???
>> s.p = [32 35; 36 37 39]
Error using vertcat
CAT arguments dimensions are not consistent.
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!