Extract Structure as a Matrix

1 visualización (últimos 30 días)
Jacob Brinkmann
Jacob Brinkmann el 11 de Dic. de 2012
Hi, thanks for your time.
I have a 1D structure array (1x8 struct) which has a field in it which is a 1D vector (1x4 double) that I would like to average.
But, when I try to extract the matricies, they come back "one at a time" instead of as a matrix (see example below)
Is there a really simple way to extract as a matrix?
>> src_telemetry.OBC_plate_temp
ans =
295.0805 295.0250 294.3839 294.2239
ans =
290.2544 290.2015 289.5120 289.4303
ans =
285.0093 284.9753 284.2140 284.2107
ans =
270.4360 270.3716 269.4591 269.6826
ans =
280.1255 280.0913 279.2793 279.3491
ans =
304.4068 304.3511 303.7728 303.4941
ans =
313.9472 313.9159 313.4091 313.0279
ans =
299.5953 299.5354 298.9181 298.7053
  1 comentario
Jacob Brinkmann
Jacob Brinkmann el 11 de Dic. de 2012
so far this is all I can come up with:
for i = 1:numel(src_telemetry)
ans(i,:) = src_telemetry(i).OBC_plate_temp;
end

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 11 de Dic. de 2012
mean(vertcat(src_telemetry.OBC_plate_temp),1);
  2 comentarios
Jacob Brinkmann
Jacob Brinkmann el 11 de Dic. de 2012
Thank you! exactly what I wanted.
Matt J
Matt J el 11 de Dic. de 2012
It does of course beg the question as to whether you need to be working with structs in the first place. If you need to convert to matrix form, maybe matrix form is the way you should be storing things.

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

Community Treasure Hunt

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

Start Hunting!

Translated by