How to convert a 1XM array into NXM array?

조회 수: 2 (최근 30일)
theblueeyeswhitedragon
theblueeyeswhitedragon 2018년 8월 23일
댓글: theblueeyeswhitedragon 2018년 8월 23일
I have a 1x12 array, where each element is a vector of doubles (the vectors have different lengths). How can I convert to a NX12 array, where N is the length of the vector with most elements.

채택된 답변

Stephen23
Stephen23 2018년 8월 23일
편집: Stephen23 2018년 8월 23일
You could do this yourself, but by far the simplest solution is to download Jos's excellent padcat:
If C is your 1x12 cell array, then just do this:
padcat(C{:})
  댓글 수: 1
theblueeyeswhitedragon
theblueeyeswhitedragon 2018년 8월 23일
The 1x12 cell array had a few empty vectors as elements. This caused the function to give a subscripted assignment dimension mismatch error in X = cat(dim, varargin{:})
Replaced those vectors with nan and it worked fine. Thanks.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by