I have a 20x1 vertical matrix. I want to take the averages of the pairs in order and display them in another matrix. How?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
To elaborate. I want to average the first and second numbers, third and fourth numbers, etc.. and display them again in a 10x1 matrix.
0 commentaires
Réponse acceptée
Image Analyst
le 28 Juin 2012
Modifié(e) : Image Analyst
le 28 Juin 2012
Try this:
m = randi(5, [20 1]) % Generate sample data
% Reshape to a 10 by 2 array.
reshapedMatrix = reshape(m, [10,2])
% Get the means going across columns (within a row)
meansOfPairs = mean(reshapedMatrix, 2)
0 commentaires
Plus de réponses (1)
Honglei Chen
le 28 Juin 2012
Modifié(e) : Honglei Chen
le 28 Juin 2012
x = rand(20,1);
y = transpose(mean(reshape(x,2,10)))
0 commentaires
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!