필터 지우기
필터 지우기

How do I create an array from one field of an array of structs?

조회 수: 1 (최근 30일)
Sam Da
Sam Da 2011년 2월 12일
I have an array of structs.
Each struct has following: name (string) value (double)
I want to create an array of names from names in each struct.
E.g. if I have a an array of structs called DateStruct I can do the following for i=1:25 NameArray(i) = DateStruct(i).name; end
But I want to achieve this through something like: NameArray = DateStruct(1:end).name;
When I do the above the NameArray is just 1x1 and prints only the first name.

채택된 답변

Walter Roberson
Walter Roberson 2011년 2월 12일
NameArray = {DateStruct.name}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by