vertically concatenate struct values from the same field

3 visualizaciones (últimos 30 días)
Rupeng Li
Rupeng Li el 27 de Jul. de 2020
Editada: Stephen23 el 23 de Feb. de 2022
Hi I encountered an issue in vertically concatenation of struct values from the same field. e.g. given S1
[S1(1:10).vals] = deal([1,2,3])
what I want to achieve is to extract all values from the field 'vals' of struct 'S1'. I could do it in a for loop so that
t= [];
for i = 1: 10
t = [t;S1(i).vals];
end
Since such commands appears frequently, is there a neater code for this purposes using structfun?
Any suggestion would be appreciated!

Respuesta aceptada

Stephen23
Stephen23 el 27 de Jul. de 2020
Editada: Stephen23 el 23 de Feb. de 2022
  1 comentario
Rupeng Li
Rupeng Li el 27 de Jul. de 2020
Editada: Rupeng Li el 27 de Jul. de 2020
Thanks! that's very neat. Also thanks for your supplementary materials. The comma seperated list looks powerful.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by