Opposite of repmat() ? Collapse an array with repetitions

조회 수: 2 (최근 30일)
Douglas Anderson
Douglas Anderson 2015년 3월 13일
답변: James Tursa 2015년 3월 13일
Hello!
I have an array (3 by X by Y) that is like this that I would like to collapse:
6 2 1
6 2 1
6 2 1
(let's say 32 times more)...
7 9 8
7 9 8
7 9 8
(again 32 times more)
2 1 2
2 1 2
2 1 2
(and again, and more times)...
I would like to collapse it to
6 2 1
7 9 8
2 1 2
...
Any suggestions? I figure there is an easy way to do that (perhaps with reshape()?) but haven't figured it out.
Thanks.
Doug

채택된 답변

Star Strider
Star Strider 2015년 3월 13일
I would use the unique function with the 'rows' option, although you may have to iterate over the third (‘page’) dimension in a for loop.

추가 답변 (1개)

James Tursa
James Tursa 2015년 3월 13일
reshape(your_array(1,:,:),X,Y)'

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by