Input char to fieldnames as argument

2 ビュー (過去 30 日間)
Eduard Sláma
Eduard Sláma 2018 年 6 月 19 日
コメント済み: Guillaume 2018 年 6 月 19 日
Hi, I am trying find out all names in field in structure. I have name of structure in class char and fieldnames need as argument structure. Basicaly my char without quotes. If I put as argument to fieldnames char I get error: Undefined function 'fieldnames' for input arguments of type 'char'.
Example:
Name of structure is: F05
Char which I have is: 'F05'
fieldnames('F05') % Undefined function 'fieldnames' for input arguments of type 'char'.
fieldnames(F05) % Names in field (That what I want)
So I need convert all chars automatically to names of structure which i will use in fieldnames.
Thank you for your help
  5 件のコメント
Stephen23
Stephen23 2018 年 6 月 19 日
編集済み: Stephen23 2018 年 6 月 19 日
"this solution is use function evalin"
Or you could write simpler, more efficient, less buggy code, by avoiding this situation entirely (which is what the MATLAB documentation and all experienced users recommend).
Guillaume
Guillaume 2018 年 6 月 19 日
"this solution is use function evalin"
This is what I called putting a band-aid on a bad design. It would have been a lot more beneficial to you if you had tried to solve the initial bad design. Having gone with the band-aid solution, you'll end up using more and more band-aids until your program is just a badly held together collection of band-aids. One of them will fall off and hell will break loose!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by