Working with structures
Afficher commentaires plus anciens
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 commentaire
Oleg Komarov
le 29 Mai 2012
@Michel: correct the typo noted by per isakson.
Réponses (1)
per isakson
le 29 Mai 2012
???
>> s.p = [32 35; 36 37 39]
Error using vertcat
CAT arguments dimensions are not consistent.
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!