Extracting a 2 dimensional array from a 3 dimensional matrix.
60 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ANAGHA GOURI
am 26 Feb. 2018
Kommentiert: Werner Barros
am 29 Jul. 2020
I have a 3D matrix named SM of order 17x10x181. I need to extract a 2D matrix from SM of order 10x181. What should be the command?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Feb. 2018
squeeze(SM(5,:,:))
For example. Without the squeeze it would be a 1 x 10 x 181 and the squeeze makes it 10 x 181
2 Kommentare
onur erdem korkmaz
am 20 Jun. 2018
Thank you for your answer. I want to ask an additional question. How do I add two matrices (10x81 add to another 10x81 in 17x10x81) with no for loop. (10x81 + 10x81 = 10x162)
Walter Roberson
am 20 Jun. 2018
[squeeze(SM(I, :, :), squeeze(SM(J,:,:))]
or
reshape( permute(SM([I, J], :, :), [2 3 1]), size(SM,2), [] )
Here [I, J] could be replaced by a vector of values to end up with a 10 x (81*n) array.
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!