How to add an NxN matrix with K pages ?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have an NxN matrix with K pages where each element is a complex number. I need to add the corresponding elements in this K pages. How to do it?
For eg., if A is a 6 X 6 matrix with 4 pages, then I need to obtain solution for A(:,:,1) + A(:,:,2)+A(:,:,3) + A(:,:,4). Alternatively, I felt if using sum(), sum(A,4) should give my required answer. But sum(A,3) is giving the required answer. So, which command should be used to find the sum of elements in an NxN matrix having K pages?
0 Commenti
Risposte (1)
James Tursa
il 24 Lug 2020
You are correct, sum(A,3) is the correct syntax to use. This sums across the 3rd dimension.
4 Commenti
James Tursa
il 24 Lug 2020
Modificato: James Tursa
il 24 Lug 2020
Yes. The sum(A,3) syntax works for any array sized NxNxK, and will sum all of the K pages since K is the 3rd dimension.
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!