summation of each row in a 3D matrix

2 visualizaciones (últimos 30 días)
kurdistan mohsin
kurdistan mohsin el 8 de Mayo de 2022
Editada: kurdistan mohsin el 8 de Mayo de 2022
hello all ,
I have the bellow 3D matrix and i want to find the summation value of each row separately , anyone can help?
c(n,i,1) n=10; i=10
0 1 0 0 1 0 0 1 0 1
1 0 1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 1 0 0 0 1
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 1 0 0

Respuestas (1)

Image Analyst
Image Analyst el 8 de Mayo de 2022
Editada: Image Analyst el 8 de Mayo de 2022
Why a for loop? Why not simply use sum():
m = randi(9, 2,3,4)
sumMatrix = squeeze(sum(m, 1))'
If it's because it's your homework, then yes, we can help but not provide the complete solution for you to turn in our solution as your own, because your professor wants your work, not ours.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by