Accessing values from struct array

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

 채택된 답변

추가 답변 (1개)

Wayne King
Wayne King 2012년 10월 15일
편집: Wayne King 2012년 10월 15일

0 개 추천

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

Sam Da
Sam Da 2012년 10월 15일
Thanks to you as well but the next answer is simpler I guess.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2012년 10월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by