How to transpose a cell array ?

조회 수: 266 (최근 30일)
SUSHMA MB
SUSHMA MB 2015년 12월 2일
댓글: Yuri 2023년 9월 14일
Each cell in the cell array contains a matrix, e.g.,
Suppose the cell array is
[8x1] cell
Inside which their are some matrix like
[6x2] double
[7x2] double
[6x2] double
[7x2] double
[6x2] double
[7x2] double
[6x2] double
[7x2] double
Now i want to transpose the cell array into
[1x8] cell
How to do it?

채택된 답변

SUSHMA MB
SUSHMA MB 2015년 12월 2일
reshape command works for this example well. For poly as the name of the cell array,
polyre = reshape(poly,[1 8]);

추가 답변 (1개)

the cyclist
the cyclist 2015년 12월 2일
편집: the cyclist 2015년 12월 2일
To transpose the cell array itself:
C_transposed = C';
To transpose the matrices inside:
C_inside = cellfun(@transpose,C,'UniformOutput',false)
  댓글 수: 4
Luke Aucoin
Luke Aucoin 2020년 9월 24일
I used C_transposed = C' to transform a row array of character strings into a column array of the same strings. Thanks @the cyclist.
Yuri
Yuri 2023년 9월 14일
Thanks a lot!

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by