필터 지우기
필터 지우기

How to extract number of fields and name of fields from a structure?

조회 수: 466 (최근 30일)
Mr M.
Mr M. 2016년 8월 22일
답변: kintali narendra 2018년 1월 16일
I have s.a = 1; s.b = 'abc'; s.c = []; How to extract the name of the fields: 'a', 'b', 'c'? And the number of fields: 3 (in this example)?

답변 (2개)

kintali narendra
kintali narendra 2018년 1월 16일
use length(fieldnames(structure)) to find the number of fields in a structure. In your case it is length(fieldnames(s)). To get the fieldnames use fieldnames(structure) in your case fieldnames(s) store the output in a different variable and call them.

Image Analyst
Image Analyst 2016년 8월 22일
Use the fieldnames() function.

카테고리

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