Accessing values from struct array

1 Ansicht (letzte 30 Tage)
Sam Da
Sam Da am 15 Okt. 2012
I have a giant struct array with fields: f1, f2, f3. i.e. Struct Array: StAr(i) has StAr(i).f1, StAr(i).f2,StAr(i).f3. But I want to create a new Array by just collecting all the f1 values without using a for loop. How do I achieve this?
Thanks guys

Akzeptierte Antwort

Matt J
Matt J am 15 Okt. 2012
newArray=[StAr.f1];

Weitere Antworten (1)

Wayne King
Wayne King am 15 Okt. 2012
Bearbeitet: Wayne King am 15 Okt. 2012
data = getfield(structarrayname,'f1');
For example:
mystruct = struct('f1',randn(100,1),'f2',randn(100,1),'f3',randn(100,1));
data = getfield(mystruct,'f1');
  1 Kommentar
Sam Da
Sam Da am 15 Okt. 2012
Thanks to you as well but the next answer is simpler I guess.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by