Extracting a 2 dimensional array from a 3 dimensional matrix.

If I have a 3 dimensional matrix, with rows 1 through 10, columns a through z and pages 1 through 4, how do I extract a 2 dimensional array containing the leftmost slab of data, that is, all the column "a" data for all four pages? This would be a 10 x 4 array, with all the data from columns "a" (or 1 if you prefer numeric).
I will rearrange said data, and then want to reinstall the rearranged data in its original place in the 3 dimensional matrix.
Any help would be appreciated.

 채택된 답변

Joseph Cheng
Joseph Cheng 2015년 5월 1일
편집: Joseph Cheng 2015년 5월 1일
so you have a matrix of 10 rows, 26 columns and 4 deep. That would be a 10x26x4 matrix. to get just all rows for column a for all pages is this example that is a bit easier to see
Testmat= randi(10,2,3,4);))
A = squeeze(Testmat(:,1,:))
A = A*0
Testmat(:,1,:) = A

추가 답변 (1개)

Zhuang Min Choo
Zhuang Min Choo 2018년 9월 6일

0 개 추천

What if don't use the function "squeeze" to find the answer, any other options?

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

2015년 5월 1일

댓글:

2018년 9월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by