'Assignment has more non-singleton rhs dimensions than non-singleton subscripts'. Can you guys help me fixing this error?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Pedro Vicente
le 25 Avr 2018
Modifié(e) : Walter Roberson
le 25 Avr 2018
I have a 3D matrix called a. Apit= 3x4x20. And i want a matrix U(20,1) that gives me the sum of each 20 matrix. And i was doing this way: (i is 20)
for i = 1:t
U(i,1) = sum(Apit(:,:,i));
end
And when i run, it appears that error. Can you help me?
0 commentaires
Réponse acceptée
Rik
le 25 Avr 2018
The output of sum is a vector, as the input is a 2D matrix. To calculate the sum over all rows and cols, you can use the code below:
U=squeeze(sum(sum(Apit,1),2));
Plus de réponses (0)
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!