Extract Structure as a Matrix

1 回表示 (過去 30 日間)
Jacob Brinkmann
Jacob Brinkmann 2012 年 12 月 11 日
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 Center および File ExchangeStructures についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by