How to convert a 1XM array into NXM array?

2 visualizaciones (últimos 30 días)
theblueeyeswhitedragon
theblueeyeswhitedragon el 23 de Ag. de 2018
Comentada: theblueeyeswhitedragon el 23 de Ag. de 2018
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.

Respuesta aceptada

Stephen23
Stephen23 el 23 de Ag. de 2018
Editada: Stephen23 el 23 de Ag. de 2018
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 comentario
theblueeyeswhitedragon
theblueeyeswhitedragon el 23 de Ag. de 2018
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by