Extracting fields from structure arrays

1 回表示 (過去 30 日間)
Julia
Julia 2011 年 6 月 19 日
編集済み: Thomas Carter 2019 年 6 月 6 日
Hi, I have a question about structure arrays. I run a loop which involves estimating parameters. These parameters are represented in the form of a structured array. The structured array is called coeff, it is a 1x10 array. Within it, there are several fields, but I'm only intrested in one of them called GARCH. It is a 1x1 array of type double. What I need is to extract the 10 different values of GARCH and represent them as a vector. I tried the following command:
coeff.GARCH
but it returns 10 values of GARCH which are separated by comma, so to speak. I need them to be represented as a single vector. I tried getfield command but it didn't give me what I wanted either. I was wondering if someone could please help me with this. Thanks.

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 6 月 19 日
[coeff(:).GARCH]
  3 件のコメント
Enrico
Enrico 2018 年 11 月 7 日
Long time passed, but thanks from me too.
Thomas Carter
Thomas Carter 2019 年 6 月 6 日
編集済み: Thomas Carter 2019 年 6 月 6 日
This almost gets me there:
What if coeff(1).GARSH=[1 2 3], coeff(2).GARSH=[4 5 6], coeff(3).GARSH=[7 8 9]
and I was the first element from each? I have a larger branched struct, this is simplified.
[coeff(:).GARSH(1)] doesn't work for me.
Irritatingly [coeff(1).GARSH(1)] provides 1

サインインしてコメントする。

その他の回答 (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