フィルターのクリア

Getting fieldnames from mwArray struct

2 ビュー (過去 30 日間)
Tyler
Tyler 2014 年 4 月 23 日
回答済み: Co Melissant 2014 年 8 月 20 日
Is there any way to extract all the field names from a struct stored in an mwArray? Similar to the fieldnames() command inside matlab

回答 (1 件)

Co Melissant
Co Melissant 2014 年 8 月 20 日
number of fields can be obtained using "NumberOfFields()":
const char* fields[] = {"a", "b", "c"};
mwArray a(2, 2, 3, fields);
int n = a.NumberOfFields();
individual field names can then be obtained using "GetFieldName(id)"
const char* fields[] = {"a", "b", "c"};
mwArray a(2, 2, 3, fields);
mwString tempname = a.GetFieldName(1);
const char* name = (const char*)tempname;
So using a loop all names you can get all names. Not aware of a simpler solution...

カテゴリ

Help Center および File ExchangeDeploy to C++ Applications Using mwArray API (C++03) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by