Accessing and using struct array using vectorization

Hello,
I have a cell array structured like this:
list_el =
36×3 cell array
{[ 1 3]} {0×0 double} {0×0 double}
{[ 1 5]} {0×0 double} {0×0 double}
{[ 1 7]} {0×0 double} {[ 3 5]}
...
And I use this loop to extract data to another matrix. I wonder if there is a way using vectorization to do this?
aa = zeros(size(list_el,1),2);
for i = 1: size(list_el,1)
aa(i,:) = list_el{i,1};
end
Thank you!

 Respuesta aceptada

Voss
Voss el 25 de Ag. de 2022
aa = vertcat(list_el{:,1});

3 comentarios

Walter Roberson
Walter Roberson el 25 de Ag. de 2022
Editada: Walter Roberson el 25 de Ag. de 2022
This would be more efficient than cell2mat, and can work for some datatype that cell2mat does not support. However it is typically only suitable when the cell is a vector
Askic V
Askic V el 26 de Ag. de 2022
Movida: Voss el 26 de Ag. de 2022
Walter and Voss, thank you very much for your answer. They are exactly what I was looking for. Cheers!
Voss
Voss el 26 de Ag. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 25 de Ag. de 2022

Comentada:

el 26 de Ag. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by