Extract Structure as a Matrix

4 次查看(过去 30 天)
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 个评论
Jacob Brinkmann
Jacob Brinkmann 2012-12-11
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

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2012-12-11
mean(vertcat(src_telemetry.OBC_plate_temp),1);
  2 个评论
Jacob Brinkmann
Jacob Brinkmann 2012-12-11
Thank you! exactly what I wanted.
Matt J
Matt J 2012-12-11
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by