How to sum columns of a matrix in MATLAB in specified number of columns?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
parham kianian
le 17 Jan 2020
Commenté : parham kianian
le 17 Jan 2020
I have a matrix A of size 2500*500. I want to sum each 10 columns and get the result as a matrix B of size 2500*50. that is, the first column of matrix B is the sum of first 10 columns of matrix A, the second column of matrix B is the sum of second 10 columns of matrix A and so on. Since I have too many number of matrices like A and I have to do this operation hundreds of times, it is highly time consuming to do that using for loop.
How can I do this without a for loop?
0 commentaires
Réponse acceptée
Plus de réponses (1)
KSSV
le 17 Jan 2020
A = rand(2500,500) ;
B = reshape(A,2500,10,[]) ;
iwant = squeeze(B,2) ;
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!