フィルターのクリア

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 Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by